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

   ## Description
   
   `camel get errors`, the error dev console and the camel-jbang-mcp errors 
tool listed every call that failed inside a `circuitBreaker` and was answered 
by its `onFallback` as an error that was not handled, one per call. An agent 
(or a person) reads that as nine failures of a route that in fact handled all 
nine.
   
   Traced against a `doTry`/`doCatch` around a `multicast` whose branch throws, 
which the registry records as handled, the difference is in the order of 
events, not in the registry:
   
   - The breaker runs the call on a correlated copy of the exchange with its 
own unit of work. When the call fails, `doneUow` on the copy (in the breaker's 
`finally`) fires the exchange-failed event before the fallback runs, and the 
registry records the copy's failure, not handled, correlated to the original. 
The breaker then runs the fallback on the original and sets the 
exception-caught property, but never says the failure was handled, so nothing 
follows. The registry's deduplication keeps the copy's entry, since it names 
the node that failed, and drops a later entry for the original.
   - With `doCatch` the copy is done after the failure propagated and the catch 
fired the handled event on the original, so the original's handled entry exists 
first and the copy's unhandled one is dropped.
   
   Two changes:
   
   - **camel-resilience4j**: the breaker emits the failure-handling and 
failure-handled events on the original around the fallback, the way 
`CatchProcessor` does (the handled event only when the fallback itself did not 
fail).
   - **camel-base-engine**: when the registry gets a handled failure for an 
original whose correlated copy is already recorded as not handled, it marks 
that entry handled instead of dropping the event, so the entry keeps the node 
and says the truth.
   
   Live check with a breaker route and a doTry/multicast route side by side, 
three calls each: before, breaker entries `handled=false` and multicast entries 
`handled=true`; after, all six handled, `camel get errors --handled=false` 
empty. Upgrade guide note added.
   
   ## Tests
   
   - `ResilienceFallbackErrorRegistryTest` (camel-resilience4j): two failed 
calls answered by the fallback give two registry entries, both handled, with 
the exception type; fails without the breaker change (verified by reverting it).
   - 
`ErrorRegistryDeduplicateTest.testCopyEntryIsMarkedHandledWhenTheOriginalRecovers`
 (camel-core): the doTry/multicast shape stays one handled entry; a guard for 
that path, which passed before as well since there the original's entry comes 
first.
   - The error registry tests of camel-core (18) and the fallback tests of 
camel-resilience4j (15) green.
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   
   https://claude.ai/code/session_01Bp3538HRBPMQkb5ta9xRaj


-- 
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