davsclaus opened a new pull request, #23305: URL: https://github.com/apache/camel/pull/23305
## Summary Fixes CAMEL-23521: When XML route dumping is performed via `DefaultDumpRoutesStrategy`, the output contains the opening `<routes>`, `<rests>`, or `<routeTemplates>` tag with its namespace attribute but is missing the corresponding closing tag, producing malformed XML. **Root cause:** `doDumpXml()` strips the outer container element by matching its opening and closing tags via simple string replacement. The old JAXB/Spring dumper emitted `xmlns="http://camel.apache.org/schema/spring"`, which was explicitly stripped first to produce a bare `<routes>`. The lightweight xml-io dumper (`LwModelToXMLDumper`, the current default) uses `xmlns="http://camel.apache.org/schema/xml-io"` instead. Because only the Spring namespace was handled, the regex `<routes>` never matched the opening tag (which still had the xml-io namespace attribute), but `</routes>` (no attributes) was correctly matched and removed — leaving an orphaned opening tag. **Fix:** Replace the exact `<routes>` string match with a regex `<routes(?:\s[^>]*)?>` that matches the opening tag with or without any namespace/xmlns attributes. This handles both dumpers (xml-io and Spring/JAXB) and any future dumpers regardless of their namespace conventions. ## Changes - `core/camel-core-engine/src/main/java/org/apache/camel/impl/DefaultDumpRoutesStrategy.java` — fix in `doDumpXml()`: use regex to match outer container opening tag with optional attributes - `core/camel-core/src/test/java/org/apache/camel/impl/DefaultDumpRoutesStrategyXmlTest.java` — new test verifying that dumped XML has correct structure (outer containers stripped, individual elements properly closed, `<camel>` wrapper present) ## Test plan - [x] New test `DefaultDumpRoutesStrategyXmlTest.testDumpXmlHasCorrectStructure` verifies that routes and routeTemplates dump files are well-structured (outer container stripped, individual elements present and closed, `<camel>` wrapper intact) - [x] All existing `DumpModel*` tests pass - [x] Full root build (`mvn clean install -DskipTests`) passes _Claude Code on behalf of Claus Ibsen_ -- 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]
