gnodet opened a new pull request, #27784:
URL: https://github.com/apache/camel/pull/27784
## Summary
Fix a silent write failure in `MinaHelper.writeBody()` that caused errors to
be swallowed when `sync=false`.
## Root Cause
`WriteFuture.awaitUninterruptibly(writeTimeout)` returns `true` when the
write operation **completes** within the timeout, but completion does not imply
success. When an encoder throws (or the channel closes during write), the
future completes immediately with `isWritten() == false`. The old code only
checked the return value of `awaitUninterruptibly` — it threw on timeout but
silently returned if the write completed-but-failed.
With `sync=false` there is no `ResponseHandler` to surface the error later,
so the exchange completed with no exception set, masking codec errors and
closed-channel failures entirely.
## Fix
Extend the condition in `MinaHelper.writeBody()` from:
```java
if (!future.awaitUninterruptibly(writeTimeout)) {
```
to:
```java
if (!future.awaitUninterruptibly(writeTimeout) || !future.isWritten()) {
```
Both the timeout case and the write-failure case now throw a
`CamelExchangeException` with the cause (when available from
`future.getException()`).
## Tests
Added `MinaWriteFailureTest` with a codec whose encoder always throws
`IllegalStateException`. The test verifies:
- Without the fix: `sendBody()` returns without exception (bug — silent
failure)
- With the fix: `sendBody()` throws `CamelExecutionException` →
`CamelExchangeException` → `IllegalStateException("Simulated encoder failure")`
The test was verified to **fail** on the pre-fix code and **pass** on the
fixed code.
Fixes https://issues.apache.org/jira/browse/CAMEL-25621
_Hermes Agent (Claude 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]