ffang commented on PR #3741: URL: https://github.com/apache/cxf/pull/3741#issuecomment-7107861684
> Please review the following... > > ### 1. A 202 acknowledgement that arrives first now hides the real reply (`ClientImpl.java` ~L985) > With a decoupled endpoint and `PROPAGATE_202_RESPONSE_ONEWAY_OR_PARTIAL=true`, `HTTPConduit` passes the back-channel 202 to `onMessage`, usually _before_ the decoupled reply arrives. The ack has no `PARTIAL_RESPONSE_MESSAGE` flag, so the `finally` block sets `FINISHED` and stores the ack as the exchange's in message. When the real reply arrives, the new `!isFinished(...)` checks (here and in `onMessage` around L854) stop it from being stored. `processResult` then reads the ack, `resList` is `null`, and a synchronous caller gets `IllegalEmptyResponseException`. Before this change the later reply overwrote the ack. > > Could a 202 with no body be prevented from setting `FINISHED` when a decoupled destination is configured, or be replaceable by a real response? A test where the ack arrives _before_ the reply would also help; the current tests only cover the reply arriving first. > > ### 2. A late partial response with a SOAP fault can still overwrite the reply (`ClientImpl.java` ~L854) > The new check only protects the `setInMessage` call in `onMessage`. When a partial response with a `soap:Fault` body arrives after the reply, `CheckFaultInterceptor` calls `InFaultChainInitiatorObserver`. That observer does `exchange.setInMessage(null)` and `exchange.setInFaultMessage(partial)` whether or not the exchange is finished. A synchronous caller that wakes after `FINISHED` then gets `null` from `exchange.getInMessage()` in `processResult`. `getException(exchange)` checks the in-fault message first, so the caller gets the late fault instead of the result. > > `testFaultPartialResponseAfterReply` doesn't cover this. It sets the `Exception` content directly, which goes to `ClientOutFaultObserver`, and that returns early for inbound messages. > > One option is to skip in-fault handling, or the exchange updates in `AbstractFaultChainInitiatorObserver`, once `FINISHED` is set. Another is to have the synchronous path keep a reference to the message that finished the exchange. > > ### Minor > * **The async path no longer calls the overridable `getException(Exchange)` (~L668).** The new `inbound` branch reads `message.getContent(Exception.class)` and `exchange.getOutFaultMessage()` directly. A subclass that overrides the protected `getException(Exchange)` keeps its behaviour for synchronous calls but not for async callbacks, and the in-fault message is no longer checked. A hook such as `getException(Exchange, Message)`, also used by the synchronous path, would keep the two consistent. > * **Late messages run the inbound chain while the exchange still points at the reply (~L858).** Once the exchange is finished, a late partial response or ack still runs the full chain, but `exchange.getInMessage()` returns the reply. Any interceptor that reads the current message through the exchange, rather than its `handleMessage` argument, would read or change the reply instead. It's worth checking the WS-Addressing, WS-RM and security interceptors. Thanks @coheigea, good catches. All four points are addressed in 216ff18634. **1. Ack before the reply** Confirmed: a decoupled call with `propagate202Response=true` lost the reply when the 202 arrived first. This also happens on main: the ack finished the exchange and completed the call with no result. In `onMessage`, a decoupled 202 without content is now treated as a partial response, so it no longer finishes the exchange, and the reply that follows does. New tests: - `testAcknowledgementBeforeReply` (synchronous) - `testAcknowledgementBeforeAsyncReply` - `testAcknowledgementWithoutDecoupledDestination`: a plain one-way 202 still completes the call **2. Late SOAP-fault partial response** Confirmed as well, via `InFaultChainInitiatorObserver` replacing the exchange's in and in fault messages. I went with your second option: the message that finished the exchange is kept, and the synchronous path reads its result and fault from that message rather than from the exchange. `testSoapFaultPartialResponseAfterReply` now drives the real `InFaultChainInitiatorObserver`, unlike the earlier test, which only set the `Exception` content. **Minor 1: `getException`** Both the synchronous and the asynchronous path now resolve the failure through a new protected `getException(Exchange, Message)`. While the response is still the exchange's in or in fault message, it delegates to the overridable `getException(Exchange)`, so existing overrides keep working for both paths. Covered by `testOverriddenGetExceptionForAsyncCalls`. **Minor 2: late messages and the exchange** I checked the client-side in-interceptors of WS-Addressing, WS-RM, SOAP and WS-Security. They work on the message passed to `handleMessage`, not on `exchange.getInMessage()`, so a late partial response or ack doesn't read or change the reply. Point 2 was the one place where it mattered, and keeping the finishing message takes care of it. The new tests fail without the change and pass with it. The core, http, JAX-WS fault, WS-Addressing and WS-RM decoupled tests also pass. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
