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

   # Description
   
   [CAMEL-27283](https://issues.apache.org/jira/browse/CAMEL-27283)
   
   The Routing Slip and Dynamic Router EIPs (`RoutingSlip`) wrap every step in 
the error handler of the route, and `RedeliveryErrorHandler.process` always 
returns `false`. So from the second step on, the EIP goes on in 
`continueRoutingSlip`, the code for a step that completed asynchronously, also 
when every step is a `direct:` route. That code did three things differently 
from the synchronous loop:
   
   - Its `catch` set the exception on `stepExchange`, the exchange the step ran 
on. That is a copy of the message unless the step was the first one. When the 
expression of a Dynamic Router throws (a bean method annotated with 
`@DynamicRouter`, a custom `Expression`), the original callback was called with 
the message as it was after an earlier step and without the exception: no 
`onException`, no dead letter channel, the consumer commits (a file moved to 
`.done`, a JMS message acknowledged), the reply of the last step is dropped, 
and the route goes on after the `dynamicRouter` as if the router had returned 
`null`. With `method(...)` the bean expression sets the exception on the 
exchange instead of throwing, so that case was not affected.
   - After a failed step it called the router expression again, with the failed 
exchange, before it stopped.
   - It applied `ignoreInvalidEndpoints` only at the top of the next iteration, 
so an endpoint whose producer cannot be created failed the message when it was 
the last one of the slip.
   
   Fix: `continueRoutingSlip` sets the exception on the original exchange, and 
after each step it applies `ignoreInvalidEndpoints` and checks for a failure 
before it asks for the next step, as the synchronous loop does (one small 
helper for the ignore check, used by both loops).
   
   Model: a small TLA+ model (`SlipAsync.tla`: three steps of any kind, sync, 
async, failing async, invalid endpoint, and a router call that may throw) 
checks that a failure of the router fails the message, that ignored invalid 
endpoints do not, and that the router is not asked again after a failed step. 
On main TLC finds a violation of each (for example: a sync step, an async step, 
the router throws, the message completes without the failure); with the change 
all hold (1702 distinct states).
   
   Tests: `AsyncEndpointDynamicRouterFailureTest` (camel-core, the `async:` 
test component with `delay=0`):
   
   - the router expression throws after a sync and an async step, after two 
async steps, after two `direct:` steps, and through a `@DynamicRouter` bean: 
`onException` must get the router's exception and `mock:result` nothing; in a 
`doTry` the `doCatch` must get it;
   - after an async step that fails, the router is called twice, not three 
times;
   - a routing slip with `ignoreInvalidEndpoints` and an invalid last endpoint 
after a `direct:` or an async step reaches the end of the route.
   
   On main 8 of the 9 tests fail (the one where the router fails right after 
the first step is a control: that step ran on the original exchange). With the 
change they pass, and the routing slip and dynamic router tests of camel-core 
pass (103 run, 0 failures, 2 skipped). The new class 20 times in one JVM: 180 
run, 0 failures.
   
   Upgrade guide: a 4.24 entry, as a route that went on after a failing router 
now gets the failure.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   - [x] 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): 
[CAMEL-27283](https://issues.apache.org/jira/browse/CAMEL-27283).
   
   # 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 the touched modules with 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]

Reply via email to