davsclaus opened a new pull request, #31374: URL: https://github.com/apache/camel/pull/31374
_Claude Code on behalf of Claus Ibsen (davsclaus)_ ## Backport of #31363 **Original PR:** #31363 - CAMEL-28111: camel-core - a dynamic uri keeps the uri text of the options that the endpoint evaluates for each message **Target branch:** `camel-4.18.x` **JIRA:** [CAMEL-28111](https://issues.apache.org/jira/browse/CAMEL-28111) **This is an adapted port, not a straight cherry-pick, so it needs review.** On `main` the change is driven by the `supportSimpleExpression` option metadata, which the build turns into the new `EndpointUriFactory.expressionPropertyNames()` / `expressionPathSyntax()` methods that core then uses. `camel-4.18.x` has neither that metadata nor those methods. So this port keeps the behaviour of #31363 for the components that exist on this branch, but puts it in a `SendDynamicAware` / `PollDynamicAware` for each component. The file components already work this way. ### What it does With a dynamic uri (`toD`, `enrich` with an expression, a `wireTap` with a dynamic uri, and `pollEnrich` with an expression), the options that a component evaluates as an expression for each message now keep the text of the uri as written in the route. The component then evaluates that text once against the message, as with a static `to`. A header value with `${...}` in it reaches the component as it is. If such an option is not in the uri as written, and only shows up in the computed uri (for example because a header value contains `&`), it is rejected with a `ResolveEndpointFailedException`. ### Adaptations compared with #31363 - **No metadata and no API change.** `camel-api` (`EndpointUriFactory`), the `endpoint-uri-factory.vm` template of `camel-package-maven-plugin`, the `@Metadata(supportSimpleExpression = true)` additions and the regenerated uri factories and catalog JSON are not ported. `camel-core-processor` (`SendDynamicProcessor`, `PollEnricher`) is not changed. - **`camel-support`:** the uri template logic of #31363 (`DynamicUriTemplate`) is moved here as a public class that takes the option names and path syntax as arguments. Two new base classes use it: `ExpressionOptionsSendDynamicAware` and `ExpressionOptionsPollDynamicAware`. - **New aware classes per component**, which list the same options that #31363 marks on `main`, limited to options this branch evaluates for each message: - `camel-micrometer` `MicrometerSendDynamicAware`: `metricsName` (path), `tags.`, `action`, `decrement`, `increment`, `metricsDescription`, `value` - `camel-opentelemetry-metrics` `OpenTelemetrySendDynamicAware`: `metricName` (path), `attributes.`, `action`, `decrement`, `increment`, `metricsDescription`, `value` - `camel-aws2-s3` `AWS2S3SendDynamicAware`: `bucketNameOrArn` (path), `keyName`. `destinationBucketPrefix` and `destinationBucketSuffix` are left out, because this branch does not evaluate them. - `camel-jpa` `JpaSendDynamicAware`: `parameters.` - `camel-sql` `SqlStoredSendDynamicAware`: `template` (path) - `camel-google-storage` `GoogleCloudStoragePollDynamicAware`: `downloadFileName` (pollEnrich) - `camel-mina-sftp` `MinaSftpSendDynamicAware` / `MinaSftpPollDynamicAware`, which reuse the generic file aware classes, like sftp - **`camel-file`:** `GenericFileSendDynamicAware` and `GenericFilePollDynamicAware` now extend the new base classes. They keep the uri text of the same options as `main`, and they reject such an option when it is only in the computed uri. Before, only the send side restored its options, and the poll side restored only `fileName`. The widened poll option list is the one from #31363. - **`camel-aws2-s3`:** `AWS2S3Endpoint` skips the bucket check at startup when the bucket name is a Simple expression. This is the same as #31363. - **Not covered here:** `toD` / `enrich` / `wireTap` / `pollEnrich` with `allowOptimisedComponents=false`. The aware classes are only used when optimisation is enabled, which is the default. On `main` the core change also covers that case. For the same reason, `PollDynamicFileNameOptimizeDisabledTest` keeps its current expectation (2 endpoints), and the `testNotOptimised` case of `ToDynamicExpressionOptionTest` is dropped. - `camel-hibernate`, `camel-openfga` and `camel-typesafe-ai` do not exist on this branch. - **Tests:** these are ported from #31363. They use `camel-test-junit5` instead of `camel-test-junit6`. In `ToDynamicExpressionOptionTest`, the option names of the test component come from a test `SendDynamicAware`, registered through `META-INF/services/org/apache/camel/send-dynamic/greet`, instead of from the uri factory. - **Upgrade guide:** following the project policy, the 4.18.7 note goes into `camel-4x-upgrade-guide-4_18.adoc` on `main` in a separate doc-sync PR, so it is not in this backport. - The `src/generated` service files of the new aware classes were regenerated by this branch's own build. ### Tests - `ToDynamicExpressionOptionTest` (camel-core): `toD`, `enrich` and `wireTap` with a test component that evaluates a path segment, an option and `tags.` for each message; rejection of an option that is only in the computed uri. - `PollEnrichFileExpressionOptionTest` (camel-core): `pollEnrich` with `filterFile` from a header; rejection of an option that is only in the computed uri. - `MicrometerToDynamicTagTest` (camel-micrometer) and `AWS2S3ToDynamicKeyNameTest` (camel-aws2-s3), as on `main`. 🤖 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]
