davsclaus opened a new pull request, #29754: URL: https://github.com/apache/camel/pull/29754
Fixes https://issues.apache.org/jira/browse/CAMEL-25982 The `resolveResource` option of the expressions (CAMEL-24884, 4.23.0) loads a result that starts with `resource:` and gives its content instead. Until now any scheme the resource loader knows could be loaded, from any location. **The change** (the revised proposal on the ticket): with `resolveResource=true`, a result `resource:<name>` * without a scheme is loaded from the classpath, as before; * with a scheme (`file:`, `classpath:`, `http:`, `ref:`, `bean:` ...) or with `..` in the name fails with an `IllegalArgumentException` that says to give the name without a scheme. The name without a scheme is the portable form anyway: `camel run` puts the files given on the command line on the classpath, and `camel export` puts them in `src/main/resources`, so `resource:order.json` works in both without changing it from `file:` to `classpath:` later. ```yaml - setBody: expression: groovy: expression: "counter == 1 ? 'resource:order.json' : 'resource:order-bad-email.json'" resolveResource: true ``` The `resource:` prefix on the expression text itself (`constant: "resource:file:order.json"`) is not affected. **Changes** * `ExpressionReifier.resolveResourceResult`: checks the name and loads it as `classpath:`. * `ExpressionDefinition`: the option description says the name has no scheme, why, and to let the route choose the name rather than take it straight from the message. Generated model / language / catalog JSONs, the XSDs and the YAML deserializers carry the new text (the XSD is byte-identical to what the build generates). * camel-jbang AI validator and diagnoser: the hint for a script that returns `'resource:file:x'` now says to add `resolveResource: true` *and* return the name without a scheme; with `resolveResource: true`, a returned name with a scheme is flagged. * Upgrade guide 4.24: results with `resource:file:...` drop the `file:`. **Tests** * `ResolveResourceExpressionTest` (camel-core): a name without a scheme loads; `classpath:`, `file:`, `http:`, `ref:` and `bean:` fail; `..` fails; other results untouched; off by default — 9 tests pass. * `ResolveResourceTest` (camel-yaml-dsl) passes unchanged (it already used a name without a scheme). * `SourceValidatorResourceLiteralTest` (new case for a scheme under `resolveResource: true`) and `SourceValidatorSimpleTest` pass. _Claude Code on behalf of davsclaus_ 🤖 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]
