shashank created CAMEL-26857:
--------------------------------

             Summary: camel-core - after a doCatch caught the failure of a 
called route that was redelivered, a later error handler counts its 
redeliveries on from that route
                 Key: CAMEL-26857
                 URL: https://issues.apache.org/jira/browse/CAMEL-26857
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: shashank
            Assignee: shashank


When the {{doTry}} block calls a route (such as with {{direct}}) whose error 
handler redelivers ({{maximumRedeliveries}} > 0, for example a 
CamelContext-scoped error handler) and then fails unhandled, the 
{{CamelRedeliveryCounter}} header of those redeliveries stays on the message 
when the {{doCatch}} takes over the failure. It is not marked as over, as 
CAMEL-26734 does for a step that was redelivered and then succeeded. So a later 
error handler (a failure after the {{doTry}} in the calling route, a route 
called from the {{doCatch}} or {{doFinally}} block, or a route called later) 
counts its redeliveries on from that header ({{incrementRedeliveryCounter}} 
respects a higher header, for nested error handlers) and redelivers fewer times 
than configured, or not at all.

Example: the called route redelivers 2 times and fails; the calling route has 
{{maximumRedeliveries(3)}} and a step after the {{doTry}} that fails. That step 
gets 1 redelivery instead of 3. When the {{doTry}} fails in the route itself, 
no redelivery runs inside the {{doTry}}, and the step gets its 3 redeliveries.

This is not a regression: before CAMEL-26447 the exchange stayed failure 
handled after the {{doCatch}}, so the later error handlers did not run at all; 
and for the route called from the {{doCatch}} block the same holds on main 
since CAMEL-26434. It is the next difference from the {{doTry}} that fails in 
the route.

Possible fix: mark the redelivery as over when the {{doCatch}} takes over the 
exception, as {{markRedeliveryOver}} does for a recovered step (CAMEL-26734); 
the redelivery headers stay readable in the {{doCatch}} block. This needs a 
small helper in {{RedeliveryErrorHandler}} (the 
{{CamelErrorHandlerRedeliveryOver}} property is private there) that 
{{CatchProcessor}} can call. Test: the example above, with the in-route 
{{doTry}} as the control.

Found while working on CAMEL-26447 (apache/camel#29584), named in its review.

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to