davsclaus opened a new pull request, #27153: URL: https://github.com/apache/camel/pull/27153
_Claude Code on behalf of davsclaus_ [CAMEL-25203](https://issues.apache.org/jira/browse/CAMEL-25203) Two gaps found while retiring the regex readers (CAMEL-25199) and checking the documentation examples (CAMEL-25182). ### Routes kept in local variables (Java DSL parser) A route built in steps was not read: ```java RouteDefinition route = from("direct:start").routeId("start"); route.split().body(); route.to("mock:split"); AggregateDefinition agg = from("direct:joinBrothers").aggregate(header("type"), strategy); agg.completionSize(2); ``` The parser took the declaration for a constant, so no route was built, and it skipped `route.to(...)`. Now: - A declaration whose value starts with a route builder entry (`from`, `rest`, `routeTemplate`, `onException`, ...), or continues such a local, is replayed where it is declared. - The result is kept under its name, and later statements on that name continue it. - Other locals (a `Predicate`, a value) stay values as before. This was the one shape where the old regex reader found a route the parser did not (3 camel-core tests). camel-core's test sources now give 5 more routes. ### setHeaders / setVariables with plain values (model) `setHeaders(Map.of("foo", "ABC"))` or `setHeaders("count", 5)` wrapped each plain value in a Java-only constant expression (`ExpressionBuilder.constantExpression`). No dumper can write that: the Java dumper wrote `expression("")`, and XML and YAML have no form for it. A String, number, boolean or char is now the `constant` language: `ConstantExpression`, with the value's type as the result type when it is not a String. The value at runtime is the same, type included, and every DSL can write it. Other objects keep the Java constant expression. The new `ExpressionNodeHelper.toConstantExpression` is used by `SetHeadersDefinition` and `SetVariablesDefinition`. ### Tests - `LwJavaParserTest`: - a route and an aggregate kept in local variables, continued later; - a local Predicate stays a value; - `setHeaders(Map.of(...))` dumps as `constant(...)`. - `SetHeadersProcessorTest.testPlainValuesKeepTheirTypeAndAreTheConstantLanguage`: an Integer header stays an Integer, a Boolean a Boolean, and the model has `ConstantExpression`. - camel-java-io: 174; camel-core SetHeaders/SetVariables: 23; camel-xml-io: 415; camel-yaml-io: 165 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
