Claus Ibsen created CAMEL-25079:
-----------------------------------

             Summary: camel-yaml-io, camel-java-io - Route dumpers produce 
invalid YAML and Java: fix bugs found in a deep review
                 Key: CAMEL-25079
                 URL: https://issues.apache.org/jira/browse/CAMEL-25079
             Project: Camel
          Issue Type: Bug
          Components: camel-core
            Reporter: Claus Ibsen


A deep review of the route dumpers to YAML and Java (camel-yaml-io, 
camel-java-io), which are used by the dev console route-dump, JMX, dumpRoutes, 
camel-jbang and the TUI, found the bugs below. Each one was reproduced against 
4.23.0-SNAPSHOT and has a test that fails without the fix 
(LwModelToJavaDumperTest, YamlPrinterRoundTripTest, YamlWriterEdgeCasesTest).

# *The Java dump of a route template, rest, route configuration or rest 
configuration is not valid Java* (such as .routeTemplate().id("tpl")...). The 
dumper used the generated generic writer instead of the Java DSL writers that 
JavaDslCompileTest compiles.
# *The Java dump of a multi-line expression is not valid Java*, as a line break 
was not escaped in the string literal.
# *The YAML dump is not valid YAML, or reads back as another value, for common 
strings*: a trailing colon (log("Processing:")), a leading , ] or }, a carriage 
return, a multi-line value whose first line starts with a space, more than one 
trailing line break, and text that YAML reads as a number (007, +5, 1., .inf).
# *The YAML dump turns text attributes into numbers*: setHeader("007") was 
dumped as 7, 1d as 1.0, 1e3 as 1000.0, and a template default 0800 as 800. A 
value is now only a number when it is written as that number.
# *dumpDataFormatsAsYaml writes the dataFormats twice and as one map*, so it 
could not be loaded, and two data formats of the same kind overwrote each 
other. It is now a list of data formats, as the YAML DSL loads them.

*Not changed (for a later look, these are in the generated writers)*
* The YAML dump of a rest loses the verb (get/post) and uses keys the YAML DSL 
does not accept (verbs, params, responseMsgs).
* The YAML dump of route templates and templated routes uses 
templateParameter/templateBean and parameter/bean instead of parameters/beans.
* The Java dump of circuitBreaker writes onFallback before the steps, so the 
steps go into the fallback.
* resolvePlaceholders for routes created from templates uses the parameters of 
the last route (YAML) or none (Java).
* dumpBeansAsYaml is built without escaping.

_Claude Code on behalf of Claus Ibsen_




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

Reply via email to