Claus Ibsen created CAMEL-26750:
-----------------------------------

             Summary: camel-core-model - circuitBreaker: the steps of an 
onFallback loaded from YAML or XML have the wrong route id in the message 
history and the error registry
                 Key: CAMEL-26750
                 URL: https://issues.apache.org/jira/browse/CAMEL-26750
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Claus Ibsen
            Assignee: Claus Ibsen
             Fix For: 4.24.0


A circuit breaker whose onFallback is loaded from YAML or XML gives the steps 
nested in the fallback the wrong route id. In the message history, and so in 
the error registry ({{camel get errors}}, the dev console, the TUI), the route 
of such a step is the id of the first step of the fallback instead of the route.

For example, with the fail-well/circuit-breaker example (an onFallback with a 
choice), the errors recorded while the breaker is open say {{routeId: 
choice1}}, and the message history says {{choice1[setBody1]}} instead of 
{{stock-check[setBody1]}}.

*Cause*

A loader builds the onFallback with its steps before it sets it on the circuit 
breaker with {{CircuitBreakerDefinition.setOnFallback}}. Only the fluent 
{{onFallback()}} gives the fallback and its steps a parent; {{setOnFallback}} 
did not, and {{RouteDefinitionHelper.initParent}} does not reach them either, 
as the fallback is not among the outputs of the circuit breaker. The message 
history takes the route of a step by walking up its parents 
({{CamelContextHelper.getRouteId}}), so for a step inside the choice it stops 
at the choice. The copy constructor has the same gap: a copied fallback keeps 
the parent of the original circuit breaker (route templates, kamelets).

This is not a regression of CAMEL-24700; {{setOnFallback}} never set the 
parents.

*Fix*

{{setOnFallback}} and the copy constructor give the fallback and its steps the 
circuit breaker as their parent, as {{onFallback()}} does. The model is shared, 
so camel-resilience4j and camel-microprofile-fault-tolerance both get it.

_Claude Code on behalf of davsclaus_



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

Reply via email to