[ 
https://issues.apache.org/jira/browse/CAMEL-24775?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-24775:
--------------------------------
    Fix Version/s: 4.23.0

> camel-core - BeanFactoryDefinition.type is required in the schemas but 
> optional at runtime for scripted and builder beans
> -------------------------------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-24775
>                 URL: https://issues.apache.org/jira/browse/CAMEL-24775
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core, camel-xml-io, camel-yaml-dsl
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Major
>             Fix For: 4.23.0
>
>
> Found while checking the documentation examples (CAMEL-24773): the three 
> {{<templateBean scriptLanguage="groovy">}} blocks of 
> route-template-bean-binding.adoc have no {{type}}, which {{camel-spring.xsd}} 
> rejects, while the runtime and the Java DSL do not need 
> it.{{BeanFactoryDefinition.type}} is {{@XmlAttribute(required = true)}} since 
> CAMEL-17611 (2022), when {{type}} was the kind discriminator ({{#class}}, 
> {{#type}}, {{bean}}, {{groovy}}, {{joor}}...). CAMEL-19953 (2023) moved the 
> kind to {{scriptLanguage}} and redefined {{type}} as the class name, but the 
> {{required}} stayed. For a bean created by a script the class is genuinely 
> optional:* {{BeanModelHelper.bind()}} (route template and kamelet local 
> beans) falls back to {{Object.class}} when {{type}} is null* the Java DSL 
> {{templateBean(name, language, script)}} sets no type at all 
> (KameletLocalBeanGroovyTest, KameletEipAggregateGroovyTest...)* 
> {{BeanModelHelper.newInstance()}} ({{<beans><bean>}}) fails with a 
> NullPointerException at {{type.startsWith("#")}} before it reaches the script 
> or builder branch, so there the type is required by accidentThe single 
> annotation fans out to four generated artifacts that disagree with the 
> runtime: {{camel-spring.xsd}} (Spring XML rejects a scripted bean without 
> type), {{camel-xml-io.xsd}} (the xml-io parser accepts it), 
> {{camelYamlDsl.json}} (the YAML validator, {{camel validate}}, the TUI and 
> the MCP tools reject it; the YAML runtime loader accepts it), and the catalog 
> {{beanFactory.json}} (every doc table says required).Fix: drop {{required = 
> true}} on {{type}} (keep it on {{name}}), and make {{newInstance()}} match 
> the model: {{Object.class}} fallback for the script path as in {{bind()}}, 
> null-safe builder path, and a clear IllegalArgumentException for a class or 
> factory bean without a type instead of the NPE. Update the description of 
> {{type}}, regenerate the model JSON, both XSDs, the YAML schema and the 
> catalog, add tests for a scripted bean without type in xml-io, YAML (loader 
> and validator) and Spring XML, and note the schema relaxation in the 4.23 
> upgrade guide._Claude Code on behalf of davsclaus_



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

Reply via email to