allthingssecurity opened a new pull request, #30305: URL: https://github.com/apache/camel/pull/30305
# Description [CAMEL-27089](https://issues.apache.org/jira/browse/CAMEL-27089) A parallel Multicast, Split or Recipient List submits its task, and then one task per part, to its thread pool and returns `false`; the last part to be aggregated calls the callback. When the route is removed, `MulticastProcessor.doShutdown` (and `RecipientList.doShutdown`) shut that pool down with `shutdownNow`. The parts still queued in the pool are dropped, and the exchange waits for them for ever. That happens when a route is stopped with a timeout that runs out (the default graceful timeout, or `stopRoute(id, timeout, unit)`) and then removed, which is also what a route reload does, while an exchange still waits for a part, for example a slow part on a busy pool. Then a synchronous caller (a `ProducerTemplate` request, a `direct` caller) waits for ever, and the exchange stays in the in-flight registry with its unit of work never done. Fix: the processor keeps its parallel tasks that are not done (a task leaves the set when it sets its `done` flag, on every path: all parts aggregated, timeout, failure, rejection). After it has shut down its own thread pool, `doShutdown` fails each remaining task with a `RouteStoppingException` through `doFailed`, which uses the same `done` flag, so the callback is called once even when a part that was running ends at the same time. The pool is now shut down before the outputs and the aggregation strategy, so the failed exchange still goes through `onCompletion` of the strategy. A user-supplied pool that the EIP does not shut down is not affected: its parts still run. I checked the protocol with a small TLA+ model (the task and two parts on the pool, route stop with graceful wait or timeout, route removal with `shutdownNow`, running parts that end after the shutdown). On main "once the route is removed and nothing is left to run, the exchange was completed" is violated (trace: send, stop, timeout, remove; 36 distinct states). Failing the tasks without the `done` flag breaks "the callback is called at most once" (55 states). With the change both hold (54 states), and the graceful and forced paths that complete the exchange are still reachable. Tests: `ParallelProcessingRemoveRouteTest` uses a pool of one thread for each EIP, keeps that thread busy in the first part, stops the route with a 100 ms timeout and removes it, then expects the exchange to complete with an exception and nothing left in flight. On main the three tests (Multicast, Split, Recipient List) time out. With the change they pass, the multicast, split, recipient list, shutdown and remove route tests of camel-core pass (746 run, 0 failures; 1 error in `DumpModelAsYamlSplitNestedChoiceEndRouteTest`, a `NoClassDefFoundError` of the YAML dumper from my local offline build, unrelated), and the new test class passes 20 times in one JVM (60/60). Related: CAMEL-27088 (Delay, Throttle and Threads EIP) fixes the same drop for the EIPs that queue the whole exchange. # 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-27089](https://issues.apache.org/jira/browse/CAMEL-27089). # 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 core modules with the formatter and import-sort plugins; no option, doc or generated file changes. 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]
