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

   Fixes [CAMEL-24576](https://issues.apache.org/jira/browse/CAMEL-24576).
   
   The `dynamic-router-control` producer built subscriptions entirely from 
values carried on the incoming
   message. `subscribeFromMessage` and `subscribeFromHeaders` read every 
parameter from the message body
   or headers, and `DynamicRouterControlService.obtainPredicateFromExpression` 
then resolved whichever
   language the message named and compiled the supplied expression into a 
filter retained in the
   channel's rule base.
   
   Elsewhere in Camel, taking a template or script from the message is an 
explicit opt-in that defaults
   to off — `allowTemplateFromHeader` on `camel-language` and on the 
`ResourceEndpoint`-based template
   components. The control endpoint had no equivalent, so a route author had no 
way to say that the
   predicate should come from the endpoint rather than from message content.
   
   ## Changes
   
   **`allowPredicateFromMessage` on the control endpoint, default `false`.** 
When it is `false`, a
   control message that supplies a `predicate` or an `expressionLanguage` is 
rejected with an
   `IllegalArgumentException`, and the values configured on the endpoint are 
used instead. The option
   is annotated `security = "insecure:dev"`, so under `camel.main.profile = 
prod` an endpoint that
   enables it will not start unless `camel.security.insecureDevPolicy` is 
relaxed.
   
   The `predicateBean` path is deliberately unchanged: it selects a `Predicate` 
that the route author
   bound in the registry, so the message only picks from what the author 
already provided. The JMX
   operations on `DynamicRouterControlService` are also unchanged — management 
access is operator
   territory, and the gate belongs on the message path.
   
   **`resolveStaticUri` keeps `allowPredicateFromMessage` on the optimised 
URI.** `toD` strips the whole
   query and replays the subscription parameters as headers. The flag must not 
travel that way, or it
   would become settable from a message, so it is deliberately absent from 
`URI_PARAMS_TO_HEADER_NAMES`
   and is instead retained on the static endpoint URI, where only the route 
author can set it. Without
   this the flag silently reverted to `false` under `toD` — caught by 
`DynamicRouterSendDynamicAwareIT`.
   
   **Endpoint fallback for the remaining subscription parameters.** 
`subscribeFromHeaders` never
   consulted the endpoint configuration, so the URI-parameter form documented 
for the control component
   only ever worked through `toD`. Parameters now fall back to the configured 
values when the message
   does not carry them, which also gives a participant a way to send only what 
identifies it and let the
   endpoint supply the predicate.
   
   **`allowedSchemes` on the `dynamic-router` endpoint.** 
`DynamicRouterRecipientListHelper` built the
   component's `RecipientList` without ever calling `setAllowedSchemes`, so the 
allow-list added for the
   recipientList/toD family in CAMEL-24298 did not reach a subscription's 
`destinationUri`. The option
   is unset by default, which allows any scheme and matches the previous 
behaviour.
   
   ## Compatibility
   
   This changes a default. A deployment that today lets control messages carry 
their own predicate — the
   multi-JVM bridge shown in the component documentation — must now set 
`allowPredicateFromMessage=true`
   on the control endpoint, or switch those subscriptions to `predicateBean`. 
Documented in the 4.23
   upgrade guide.
   
   ## Tests
   
   `mvn verify` on `components/camel-dynamic-router` is green: 134 unit tests 
and 21 integration tests.
   
   New coverage in `DynamicRouterControlProducerTest`: the predicate and the 
expression language are each
   rejected from headers and from a control-message body, on both `subscribe` 
and `update`; the
   endpoint-configured predicate is used when the message supplies none; all 
subscription parameters fall
   back to the endpoint; and `predicateBean` still works with the gate closed. 
`DynamicRouterControlChannelSendDynamicAwareTest`
   covers the flag surviving `resolveStaticUri`, and 
`DynamicRouterRecipientListHelperTest` covers the
   `allowedSchemes` wiring. The integration tests that deliberately let the 
control message supply the
   predicate now opt in.
   
   Assertions follow the JUnit style already used throughout this module — 
`camel-dynamic-router` does
   not depend on AssertJ, and adding the dependency for a handful of new 
assertions did not seem worth it
   here.
   
   _Claude Code on behalf of oscerd_
   


-- 
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