You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Claus Ibsen (Jira)" <ji...@apache.org> on 2026/06/16 12:02:00 UTC

[jira] [Resolved] (CAMEL-23763) camel-xml-io ModelWriter writes kamelet child element as route attribute breaking XML round-trip

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

Claus Ibsen resolved CAMEL-23763.
---------------------------------
    Resolution: Fixed

> camel-xml-io ModelWriter writes kamelet child element as route attribute breaking XML round-trip
> ------------------------------------------------------------------------------------------------
>
>                 Key: CAMEL-23763
>                 URL: https://issues.apache.org/jira/browse/CAMEL-23763
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>              Labels: eip
>             Fix For: 4.21.0
>
>
> When a route contains a {{<kamelet name="my-processor"/>}} child element, the XML ModelWriter in camel-xml-io writes it back as a {{kamelet="false"}} attribute on the {{<route>}} element instead of preserving the {{<kamelet>}} child element. This breaks XML round-trip (parse, write, re-parse).
> *Input XML:*
> {code:xml}
> <routes xmlns="http://camel.apache.org/schema/xml-io">
>   <route>
>     <from uri="direct:start"/>
>     <kamelet name="my-processor"/>
>     <to uri="mock:result"/>
>   </route>
> </routes>
> {code}
> *Written XML (incorrect):*
> {code:xml}
> <route kamelet="false" xmlns="http://camel.apache.org/schema/xml-io">
>   <from uri="direct:start"/>
>   <to uri="mock:result"/>
> </route>
> {code}
> The {{<kamelet>}} child element is lost entirely, and a spurious {{kamelet="false"}} attribute appears on the {{<route>}} element. Re-parsing the written XML then fails with: {{Unexpected attribute 'kamelet'}}.
> *Root cause:* {{RouteDefinition}} has a boolean {{kamelet}} field that is a runtime transient (used internally to mark whether a route originates from a kamelet). The XML ModelWriter picks up this boolean field and writes it as an XML attribute, while the actual {{KameletDefinition}} child element (the Kamelet EIP) is not written. The writer should never serialize the transient boolean and should always write the {{KameletDefinition}} child element.
> *Discovered while:* adding compile-validation tests for the new Java DSL model writer (CAMEL-23757). The kamelet XML test file had to be placed in camel-java-io test resources instead of camel-xml-io to avoid breaking the ModelWriterTest round-trip tests.



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