davsclaus opened a new pull request, #27021: URL: https://github.com/apache/camel/pull/27021
[CAMEL-25115](https://issues.apache.org/jira/browse/CAMEL-25115) Fixes bugs in the failure paths of the error handler. Each fix applies to both the non-redelivery (`SimpleTask`) and the redelivery (`RedeliveryTask`) path. ### Fixed 1. **A throwing `onWhen` predicate:** it is now regarded as not matching and logged at WARN, so another `onException` (or the error handler) handles the exchange. Before, the exception escaped from the error handler. 2. **A throwing `handled` / `continued` / `retryWhile` predicate:** it is logged at WARN and regarded as `false`. The original exception stays as the exchange exception, with the predicate exception attached as suppressed, and the exchange still goes to the `onException` outputs or the dead letter channel. 3. **`FatalFallbackErrorHandler`:** the circular-detection entries are now tied to the exchange instance. The old mutable deque was shared by copies of the exchange (for example from a parallel splitter), which could report a false circular error handler. The property is now removed when it becomes empty. 4. **`onPrepareFailure` that fails:** the exchange is no longer delivered to the dead letter queue or failure processor with the exception set on it. The new exception is handled according to `deadLetterHandleNewException`, with the original exception attached as suppressed. This covers both a thrown exception and one the wrapped processor sets on the exchange. 5. **`DefaultErrorRegistry`:** the handled flag now comes from the exchange. Before, an exception processed by `onException` without `handled(true)` was recorded as handled. A `doCatch` is still recorded as handled. 6. **`onRedelivery` that fails:** this is now treated as a new failure. Before, the exchange was redelivered with the exception still on it. 7. **After `continued(true)`:** a later, unrelated exception no longer gets the continued exception attached as suppressed. 8. **`OnCompletionProcessor`:** - It resets `failureHandled` before running the completion, so an `onException` can now handle a failure inside an `onFailureOnly` completion. - A handled failure inside the completion no longer leaks `EXCEPTION_CAUGHT` or the error-handler-handled flag onto a successful exchange. 9. **`RedeliveryTask.run()`:** it now releases the pooled task when it catches an unexpected exception. ### Behaviour changes - `OnExceptionHandledThrowsExceptionTest` is updated to the new contract. A `handled` predicate that throws is regarded as not handled, so the `onException` outputs are processed. The exchange then fails with the original `IOException`, which carries the predicate's `IllegalArgumentException` as suppressed. Before, the predicate exception replaced the original and the outputs were skipped. - The `onPrepareFailure` behaviour is documented in `dead-letter-channel.adoc`. - The 4.23 upgrade guide has entries for: - throwing predicates - `onPrepareFailure` - the error registry handled flag ### Not changed - The design of the recursion detection: a route runs twice before the circuit is detected, and a dead letter queue route inherits the dead letter channel. - The `NoErrorHandler` bridge case. - The `isSame` heuristic in the error handler. - The `ERRORHANDLER_CIRCUIT_DETECTED` property, which is set but not used. - The unused redelivery policy branch in `SimpleTask`, tracked in CAMEL-24980. ### Tests - New `ErrorHandlerFailurePathsTest` with 10 tests. Every one of them fails without the fix. The parallel split test is deterministic: it sends 4 items and expects exactly 4 messages. - The full `camel-core` suite passes: 7838 tests, 0 failures. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
