ffang commented on PR #3741: URL: https://github.com/apache/cxf/pull/3741#issuecomment-7136766617
> Thanks, this looks good. One minor point left in `getException(Exchange, Message)`: > > The re-check after `getException(exchange)` only looks at the in-fault message, but `getException(exchange)` also reads `exchange.getInMessage()`. During async processing the exchange isn't `FINISHED` yet, so a partial response can pass `receive()` and replace the in message between the `response == exchange.getInMessage()` check and that read. The reply then gets the partial's exception instead of its own. If the partial has no exception, the reply's own failure is dropped and the callback reports success. > > Re-checking `response == exchange.getInMessage()` after the call would close this. Alternatively, do the check and the call inside `synchronized (exchange)`, which is the lock `receive()` already holds when it sets the in message. Thanks @coheigea, good catch. Fixed in 3c107c85e3. `getException(Exchange, Message)` now re-checks `response == exchange.getInMessage()` after calling `getException(exchange)`, next to the in-fault check. A message that arrives later never makes the response the in message again, so if both are unchanged, `getException(Exchange)` can't have read a late message. Otherwise the result is discarded and the response's own failure is used. I preferred the re-check to `synchronized (exchange)` because the in fault message is set outside that lock, so its re-check is needed anyway, and it avoids calling an overridable method while holding the lock. Two new tests replace the in message with a partial response inside that window. Both fail without the fix: - `testPartialResponseArrivingWhileAsyncFailureIsResolved`: the partial has a failure, and the reply's callback must still get the result. - `testPartialResponseArrivingWhileAsyncFailureIsResolvedKeepsTheFailure`: the partial has no failure, and the reply's own failure must not be dropped. -- 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]
