allthingssecurity opened a new pull request, #28029:
URL: https://github.com/apache/camel/pull/28029

   # Description
   
   [CAMEL-25721](https://issues.apache.org/jira/browse/CAMEL-25721)
   
   The XML, YAML and Java route dumps (`camel transform route`, `camel validate 
normalize`, `camel.main.dumpRoutes`, the developer console) leave out an 
attribute whose value equals the `defaultValue` of its `@Metadata`: the 
generated writers pass the default to `doWriteAttribute`, which then writes 
nothing. For many options "not set" does not mean "the default", it means "the 
value of the parent level":
   
   - a rest or verb `bindingMode`, `skipBindingOnErrorCode`, 
`clientRequestValidation`, `clientResponseValidation`, `enableCORS`, 
`enableNoContentResponse` take the value of the rest, then of the rest 
configuration;
   - the redelivery policy of an `onException` is a copy of the error handler's 
policy with only the options that are set overridden;
   - a `resilience4jConfiguration` / `faultToleranceConfiguration` is layered 
over the global circuit breaker configuration;
   - a route `shutdownRoute` / `shutdownRunningTask` take the CamelContext's 
value.
   
   So a route that sets one of these to its documented default on purpose runs 
differently once it is dumped and loaded again: a verb with `bindingMode: 
"off"` under `camel.rest.bindingMode=json` replies with JSON, an `onException` 
with `redeliveryDelay: 1000` waits for the error handler's 30 s, a circuit 
breaker with `timeoutEnabled: false` under a global timeout falls back. 
`skipBindingOnErrorCode` is documented as `false` while `RestConfiguration` 
defaults to `true`, so `skipBindingOnErrorCode: false` is lost even with the 
default configuration.
   
   Change: the writer that each of `LwModelToXMLDumper`, `LwModelToYAMLDumper` 
and `LwModelToJavaDumper` creates writes these options whenever they are set: 
the six rest binding options and `shutdownRoute` / `shutdownRunningTask` by 
name (a static `INHERITED_OPTIONS` set in each dumper), and every option of a 
redelivery policy, a `resilience4jConfiguration` and a 
`faultToleranceConfiguration` while that element is written. Other options are 
still left out at their default. Writing every set option was tried first and 
rejected: the Java DSL sets `pretty="false"` on every `simple` and the 
`library` of a `json` data format, so the dumps of Java routes filled up and 
the camel-java-io round-trip tests failed. The generated writers, their 
templates and the model are not changed (nothing regenerated).
   
   What users can notice: dumps show these options when a route sets them to 
their default value (before, they were left out). A note is added to the 4.24 
upgrade guide.
   
   Tests:
   - New `YamlDumpExplicitDefaultValuesTest` (camel-yaml-dsl, 3 tests) and 
`XmlDumpExplicitDefaultValuesTest` (camel-xml-io-dsl, 2 tests): load the 
routes, run them, dump them, load the dump and run it again (rest verbs through 
a seda-based rest consumer). New 
`LwModelToJavaDumperTest.testDumpOptionsSetToTheirDefaultValue`.
   - Without the change all 6 fail: `expected: "{format=raw}" but was: 
"{"format":"raw"}"`, `expected: "{"error":"bad request"}" but was: "{error=bad 
request}"`, `expected: <200 stored> but was: <415 null>`, `expected: "handled" 
but was: "not redelivered within 10 seconds"` (YAML and XML), and the Java dump 
without `.bindingMode("off")`.
   - With the change (formatter and import sort applied first; the tests ran on 
the commit tree): camel-xml-io 426 run, 0 failures (2 skipped); camel-yaml-io 
189, 0 failures; camel-java-io 188, 0 failures (1 skipped; includes the Java 
round-trip tests over the XML corpus); camel-xml-io-dsl 72, 0 failures; 
camel-yaml-dsl 486, 0 failures; camel-yaml-dsl-deserializers 2, 0 failures; 
camel-yaml-dsl-validator 240, 1 failure: `EipDocExamplesTest` reads the `wasm` 
language page from the catalog of my local snapshot, the language was removed 
on main by CAMEL-25677 (not related); `YamlRoundTripTest` passes.
   
   What is not changed: the documented default of `skipBindingOnErrorCode` 
(`false`, runtime `true`); a top-level `errorHandler` and the intercepts are 
still not dumped (CAMEL-25651, in progress, touches `LwModelToYAMLDumper` too; 
a small rebase may be needed whichever merges second).
   
   Also run with the change: the dump tests of camel-core (`*Dump*` and the 
nested-choice issue tests that dump, 70 run) and camel-management (`*Dump*`, 
`ManagedFromRest*`, 34 run), 0 failures.
   
   What was not run: the full root build; the camel-jbang tests that compare 
dump output.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it): 
[CAMEL-25721](https://issues.apache.org/jira/browse/CAMEL-25721).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [ ] I have run `mvn clean install -DskipTests` locally from root folder 
and I have committed all auto-generated changes.
     (I built and tested the changed modules, including the formatter and 
import-sort plugins. I did not run the full root build.)
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
     This PR was prepared with Claude Code (Claude Opus 5.5). The commit 
carries a `Co-Authored-By` trailer.
   
   _Claude Code on behalf of allthingssecurity_
   
   🤖 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]

Reply via email to