davsclaus opened a new pull request, #26812:
URL: https://github.com/apache/camel/pull/26812

   [CAMEL-24981](https://issues.apache.org/jira/browse/CAMEL-24981)
   
   ## Problem
   When a redelivery attempt fails with a different exception than the previous 
attempt, the error handler keeps using the `onException` matched by the earlier 
exception, including its failure processor, `handled`/`continued` predicates, 
redelivery policy and `onRedelivery` processor. A new exception with no 
`onException` of its own is then routed to the earlier exception's 
`onException` and handled there. It never reaches the dead letter channel or 
the caller.
   
   Example: attempt 1 throws `IOException`, which matches 
`onException(IOException).maximumRedeliveries(1).handled(true)`. The redelivery 
throws `IllegalStateException`, which has no `onException`, but it is still 
handled by the `IOException` one.
   
   `RedeliveryTask.handleException` only overwrote this state when a policy 
matched and never reset it first. This behaviour dates from 2009, and nothing 
in git history or JIRA says it was intended.
   
   ## Fix
   - `handleException` now resets to the error handler defaults 
(`useErrorHandlerDefaults()`) before applying the policy that matches the 
current exception.
   - `prepare()` uses the same method, so `failureProcessor` is also cleared 
when a pooled task is reused. Before, a reused task could carry the previous 
exchange's onException route.
   
   ## Tests
   - New `OnExceptionChangedExceptionOnRedeliveryTest`: a new exception with no 
policy goes to the dead letter channel; the same with the default error handler 
(the exception reaches the caller); a new exception with its own policy uses 
that policy; repeating the same exception keeps its policy.
   - Full `core/camel-core` suite: 7497 tests, 0 failures.
   
   ## Docs
   Upgrade guide entry in `camel-4x-upgrade-guide-4_23.adoc`, because routing 
changes for routes that relied on the old behaviour. This is why I'd keep the 
change on main and not backport it.
   
   _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]

Reply via email to