gnodet opened a new pull request, #29450:
URL: https://github.com/apache/camel/pull/29450
## Summary
Fixes a bug where the camel-cxf async producer could leave a Camel exchange
stuck indefinitely when the upstream connection fails.
## Root Cause
In `CxfClientCallback.handleResponse()` and `handleException()`, the call to
`camelAsyncCallback.done(false)` appeared immediately after
`endpoint.getCxfBinding().populateExchangeFromCxfResponse(...)` with no inner
guard. Both calls shared the outer `finally` block but had no protection
between them: if `populateExchangeFromCxfResponse()` threw a runtime exception,
the `camelAsyncCallback.done(false)` line was never reached, causing the
calling thread to hang indefinitely in
`DefaultAsyncProcessorAwaitManager.await()` with no timeout, no stack trace,
and no error — just a silent freeze.
This was first observed as a flaky hang in
`CxfProducerTest.testInvokingAWrongServer` (tracked in CAMEL-26600) and worked
around by forcing `synchronous=true` on the wrong-server test endpoint.
CAMEL-26696 is the proper fix.
## Fix
Wrap `populateExchangeFromCxfResponse()` in its own inner `try/finally` in
**both** `handleResponse()` and `handleException()`, so
`camelAsyncCallback.done(false)` is always called — even if the
response-binding throws:
```java
if (!boi.getOperationInfo().isOneWay()) {
try {
endpoint.getCxfBinding().populateExchangeFromCxfResponse(camelExchange,
cxfExchange, ctx);
} finally {
// always signal the Camel callback, even if
populateExchangeFromCxfResponse throws,
// to prevent the calling thread from hanging in
DefaultAsyncProcessorAwaitManager
camelAsyncCallback.done(false);
}
}
```
## Test
Added `testInvokingAWrongServerAsync()` to `CxfProducerTest` — a test that
calls a closed port without `synchronous=true`. The class-level `@Timeout(30s)`
guards against the exchange hanging in `DefaultAsyncProcessorAwaitManager` if
`camelAsyncCallback.done()` is never called. The existing
`testInvokingAWrongServer()` (which keeps `synchronous=true`) is preserved
as-is for the synchronous path.
## Related
- CAMEL-26600: original flaky test report
- CAMEL-26696: this issue
_Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet_
--
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]