allthingssecurity opened a new pull request, #27917: URL: https://github.com/apache/camel/pull/27917
# Description [CAMEL-25678](https://issues.apache.org/jira/browse/CAMEL-25678) Every String option of an EIP is resolved with `parseString` when the route is created, which is also how route template and Kamelet parameters reach an EIP (CAMEL-25047 resolved several more of them). Two options were used as written: - **Switch EIP, case `value`.** `SwitchReifier` resolved the `uri` of each case and of `otherwise` (`staticUri` calls `parseString`), but built the table from `c.getValue().toLowerCase(Locale.ENGLISH)`. A case such as `doCase("{{tier}}", "direct:gold")` was keyed by the text `{{tier}}`, so no selector result matched it: every message went to `otherwise`, or continued after the Switch without a destination when there is no `otherwise`, and nothing was logged. This includes a route template or Kamelet parameter used as a case value. The duplicate check compared the unresolved text too, so two cases that resolve to the same value started without error. - **Dynamic Router EIP, `uriDelimiter`.** `DynamicRouterReifier` used the delimiter as written, while `RoutingSlipReifier` and `RecipientListReifier` resolve theirs. With `uriDelimiter("{{delim}}")` the slip was not split and the exchange was sent to one endpoint whose uri is the whole slip. The change resolves both with `parseString`: the case value before it is lower-cased and checked for duplicates, the delimiter before the default `,` is applied. A value without placeholders gives the same result as before. What changes for users (4.24 upgrade guide, new `=== camel-core - ...` section before `camel-dapr`, not at the end): a placeholder in these two options is now resolved, and a placeholder of a property that does not exist fails the route at startup, as for the other EIP options. The Switch documentation (and its catalog copy) now says that case values support property placeholders. On the design: the Switch documentation calls case values "literal". In CAMEL-24988 that word is used in contrast to patterns and wildcards (an asterisk is not a wildcard); the documentation says that URIs support placeholders and does not say that values do not. If a literal `{{...}}` text should stay matchable on purpose, this part of the change is the one to drop. Tests: - `SwitchEndpointTest.caseValueResolvesPropertyPlaceholder`: `doCase("{{switch.tier}}", "mock:gold")` with `switch.tier=gold`; headers `gold` and `GOLD` select the case, the literal text `{{switch.tier}}` goes to `otherwise`. - `SwitchEndpointTest.caseValueResolvesRouteTemplateParameter`: a route template with `doCase("{{tier}}", "mock:gold")`, created with `tier=silver`. - `SwitchValidationTest.rejectsDuplicateValuesAfterResolvingPlaceholders`: `doCase("{{switch.tier}}", ...)` and `doCase("gold", ...)` are rejected at startup. - New `DynamicRouterUriDelimiterPlaceholderTest`: the slip `mock:a;mock:b` with `uriDelimiter("{{slip.delimiter}}")` and `slip.delimiter=;` reaches both mocks. - Without the change all four fail: `mock://gold Body of message: 0. Expected: <first> but was: <third>` (only the literal placeholder text matched); `mock://gold Body of message: 0. Expected: <first> but was: <second>`; `Expected java.lang.Exception to be thrown, but nothing was thrown.`; and `mock://a Received message count. Expected: <1> but was: <0>`. - camel-core with the change: 8182 tests, 0 failures, 45 skipped (9583 tests, 0 failures, 47 skipped together with the core modules it builds on). Not changed, same pattern with a smaller impact (follow-ups if wanted): `RollbackReifier` uses `message` as written (only the text of the exception), and `TransformDataTypeReifier` uses `fromType`/`toType` as written (the route fails at startup with "No transformer"). What was not run: the full root build, the YAML and XML DSL modules (they build the same model, and the reifier is shared). How it was found: a Lean 4 model of the Switch dispatch table (case value, placeholder resolution, case folding) checked against the Switch documentation, then a sweep of the reifiers for String options that are not passed to `parseString`. # Target - [x] I checked that the commit is targeting the correct branch (Camel 4 uses the `main` branch) # Tracking - [ ] 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). (The ticket is drafted and not filed yet; CAMEL-25678 is a placeholder until it is.) # 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 camel-core and the core modules it depends on, 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]
