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

   ## Backport of #27725
   
   Cherry-pick of #27725 onto `camel-4.22.x`.
   
   **Original PR:** #27725 - CAMEL-25584: camel-lra - only join LRAs hosted by 
the configured LRA coordinator
   **Original author:** @oscerd
   **Target branch:** `camel-4.22.x`
   
   The code applies without changes. The upgrade-guide notes are left out, as 
they live on `main` (the 4.22.2 note is already in main's 
`camel-4x-upgrade-guide-4_22.adoc`).
   
   Tested on the branch: the camel-lra unit tests and the `LRA*IT` tests 
against the LRA coordinator container, and a full reactor build without tests.
   
   ### Original description
   
   ## Description
   
   [CAMEL-25584](https://issues.apache.org/jira/browse/CAMEL-25584)
   
   When a message with a `Long-Running-Action` header reaches a saga route, the 
LRA saga service joins that LRA by calling the URL in the header, and 
`saga:complete` / `saga:compensate` close or cancel it the same way. That URL 
was not checked against the configured LRA coordinator.
   
   - `LRASagaService.getSaga()`, which every lookup of an existing LRA goes 
through, now accepts an LRA only when its URL is under the configured 
coordinator (`coordinatorUrl` + `coordinatorContextPath`): same scheme, host 
and port (read through `java.net.URL`, so host names with an underscore work; 
case-insensitive, default ports normalized), no user info, no path parameter or 
encoded dot, slash or backslash in the path (`;`, `%2e`, `%2f`, `%5c`), and a 
normalized path under the coordinator path. Otherwise the lookup fails with an 
`IllegalArgumentException` that names the option to use, and the exchange fails 
without any call to that URL.
   - New `allowedCoordinatorUrls` option, also 
`camel.lra.allowedCoordinatorUrls` in camel-main: comma-separated further 
coordinator URLs to accept, for participants that reach the same coordinator 
under different URLs. An entry that is not an `http` or `https` URL with a host 
fails at startup.
   - LRAs started by the service come from the configured coordinator and keep 
working: the LRA ITs against the coordinator container (multi-route `MANDATORY` 
sagas, manual completion) pass unchanged.
   - Docs: the Saga EIP page. Upgrade guide: a `camel-lra` section in the 4.24 
guide, plus the 4.22.2 and 4.18.6 sections on main, as a message carrying the 
`Long-Running-Action` of another coordinator now fails. They also say that the 
LRAs the service starts itself are checked too, for a coordinator behind a 
proxy that returns LRA URLs under another base URL.
   
   ## Tests
   
   - `LRASagaServiceAllowedCoordinatorTest`: accepted and rejected LRA URLs 
(host, port, scheme, case, default port, context path, `..` segments, encoded 
and `;` dot segments, a sibling path prefix, user info, host names with an 
underscore, allowed coordinator URLs), and the startup validation.
   - `LRAPropagatedSagaTest`: through the Saga EIP, a propagated LRA of the 
configured coordinator is joined, and one of another coordinator fails the 
exchange with no call to the LRA client.
   - All the `LRA*IT` tests against the LRA coordinator container: 12 tests, 
green locally.
   
   ## Notes
   
   - This touches the same files as #27719 (`LRASagaService`, 
`LraConfigurationProperties`, the Saga EIP page and the generated camel-main 
metadata), so whichever merges second needs a rebase and a regen.
   - camel-spring-boot: `camel-lra-starter` sets the LRA options one by one, so 
it needs `allowedCoordinatorUrls` too, in the same releases, tracked in 
[CAMEL-25590](https://issues.apache.org/jira/browse/CAMEL-25590).
   - Backports to `camel-4.22.x` and `camel-4.18.x` after this is merged.
   
   _Claude Code on behalf of oscerd_
   
   🤖 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