Claus Ibsen created CAMEL-24696:
-----------------------------------

             Summary: camel-core-model: port inheritErrorHandler to a String 
field so property placeholders work
                 Key: CAMEL-24696
                 URL: https://issues.apache.org/jira/browse/CAMEL-24696
             Project: Camel
          Issue Type: Task
          Components: camel-core
            Reporter: Claus Ibsen


h3. Background

Almost every scalar attribute in the Camel model is declared as a {{String}} 
field with the real type in {{@Metadata(javaType = ...)}}, so that property 
placeholders can be used and the value is converted at route startup. Out of 
~1660 generated YAML deserializer cases, only five converted the text eagerly 
at deserialization time. CAMEL-24694 ported three of them:

* {{BeanConstructorDefinition.index}} ({{Integer}})
* {{ParamDefinition.required}} ({{Boolean}})
* {{RouteTemplateParameterDefinition.required}} ({{Boolean}})

h3. What is left

Two remain on {{Boolean}}:

* {{org.apache.camel.model.CircuitBreakerDefinition.inheritErrorHandler}}
* 
{{org.apache.camel.model.loadbalancer.FailoverLoadBalancerDefinition.inheritErrorHandler}}

The generated deserializer does 
{{target.setInheritErrorHandler(java.lang.Boolean.valueOf(val))}}, so a 
property placeholder is *not* resolved - {{Boolean.valueOf("{{myFlag}}")}} 
silently yields {{false}} rather than failing. Because of that, CAMEL-24694 
deliberately allowlisted {{inheritErrorHandler}} in the YAML validator's 
placeholder filter so validation keeps rejecting a placeholder there instead of 
accepting something the runtime gets wrong. That allowlist should be removed as 
part of this issue.

h3. Why it was not done in CAMEL-24694

Both are {{@Override}} of {{ProcessorDefinition.getInheritErrorHandler()}} 
which returns {{Boolean}}, and that contract is read by:

* {{org.apache.camel.reifier.ProcessorReifier#wrapChannel}}
* {{org.apache.camel.reifier.LoadBalanceReifier}}
* {{org.apache.camel.component.kamelet.Kamelet}}
* the generated {{ModelWriter}} / {{YamlModelWriter}} / {{JavaDslModelWriter}}
* camel-jta (the base field carries a "used for camel-jta" note)

So converting the field is a wider blast radius than the rest of CAMEL-24694 
combined, for a {{label=advanced}} flag that is seldom used and dates back to 
the early days of Camel.

h3. Options

# Keep {{getInheritErrorHandler()}} returning {{Boolean}} on 
{{ProcessorDefinition}}, add a String-valued accessor on the two subclasses, 
and move the {{parseBoolean}} into {{ProcessorReifier}} / 
{{LoadBalanceReifier}}. Doable on 4.x.
# Change the base contract to {{String}} across the hierarchy, consistent with 
the rest of the model. Public API break - better suited to Camel 5.0.

Needs a decision on whether this lands on 4.x or waits for 5.0.

h3. Done when

* a property placeholder at {{inheritErrorHandler}} resolves at route startup 
like every other scalar attribute;
* the {{inheritErrorHandler}} allowlist is removed from {{YamlValidator}} and 
its test asserts the placeholder is now accepted;
* upgrade guide entry if the public signature changes.

Related: CAMEL-24694.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to