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

   Fixes [CAMEL-25114](https://issues.apache.org/jira/browse/CAMEL-25114): bugs 
found in a deep review of doTry, doCatch and doFinally.
   
   ## Fixed
   1. **A doCatch whose onWhen predicate threw left the exchange hanging.** The 
exception was not propagated and the exchange never completed: doFinally did 
not run and a synchronous caller waited forever. The exchange now fails with 
the predicate's exception, with the original exception attached as suppressed, 
and doFinally runs.
   2. **In the Java DSL, `onWhen` was set on every doCatch of the doTry**, 
including the doCatch blocks of nested doTry blocks. The onWhen of a later 
doCatch therefore replaced the onWhen of the earlier ones. It now applies only 
to the doCatch it follows.
   3. **A nested doTry, or a doTry in a route called from a doTry, removed the 
`TryRouteBlock` marker** when it completed, instead of restoring it. Steps 
after it in the outer doTry, such as recipientList, multicast and split, then 
used the route error handler (redelivery and dead letter channel), and the 
outer doCatch was never used.
   4. **An exception thrown in doFinally was lost while an earlier exception 
was still unhandled.** The original exception is now kept, and the doFinally 
exception is added as suppressed.
   5. **doFinally, including the implicit one, removed the failure details of 
an earlier failure that happened before the doTry.** These are 
`FAILURE_ROUTE_ID`, `FAILURE_NODE_ID`, `FAILURE_ENDPOINT` and 
`FAILURE_LOCATION`. The doTry now restores them.
   6. **A doTry without any doCatch or doFinally is now rejected at startup** 
with "doTry must have one or more doCatch or doFinally blocks". The check 
existed but could never fail, so such a doTry was accepted and silently turned 
off the route error handler for its steps.
   7. **A doCatch after one that had already handled the exception still 
evaluated its onWhen and updated its counters.**
   8. **The step id (CAMEL-23616) was not set on the doCatch and doFinally 
processors.**
   
   ## Documentation
   The doTry EIP page (and its catalog copy) now describes:
   - how doCatch matches an exception: clause order first, and how that differs 
from onException;
   - that an exception escaping a doTry is not handled by the route error 
handler;
   - the suppressed exception from doFinally;
   - that `stop()` skips doFinally;
   - that a doTry must have a doCatch or doFinally.
   
   The upgrade guide has an entry.
   
   ## Existing tests changed
   - **`TransactedDoTryRecipientListTest`** (camel-spring-xml): it was the only 
route in the repository with a doTry and no doCatch/doFinally. It now has a 
doFinally, and still tests the transacted recipientList inside a doTry.
   - **`SpringTryCatchMisconfiguredTest`**: its XML has a doTry whose 
doCatch/doFinally is placed outside the doTry. That now fails earlier, with the 
new doTry message.
   
   ## Not changed
   - **Circuit breaker processors:** the processors in camel-resilience4j and 
camel-microprofile-fault-tolerance also remove the `TryRouteBlock` marker 
instead of restoring it.
   - **Model:** it accepts doTry children in any order.
   
   ## Tests
   - **New `DoTryEdgeCasesTest`** (camel-core): 8 tests, all of which fail 
without the fix. The hang test uses a bounded wait.
   - **Full suite:** camel-core and its upstream modules pass (7836 tests).
   - **camel-spring-xml:** its doTry tests pass (22), run with the changed core 
modules in the reactor.
   
   _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