allthingssecurity opened a new pull request, #26798: URL: https://github.com/apache/camel/pull/26798
# Description [CAMEL-24952](https://issues.apache.org/jira/browse/CAMEL-24952) `ThreadPerTaskSedaConsumer` (`virtualThreadPerTask`) incremented `activeTasks` only when a task started running. An exchange that was polled but whose task hadn't started yet was not in the queue, not inflight and not counted. A graceful stop therefore considered the consumer idle, and the task later ran against the stopped route and was rejected (only logged), so the message was lost. This change: `activeTasks` is incremented before `taskExecutor.execute(...)`. It's decremented, and the concurrency permit released, in the task's `finally` block, and also when `execute` throws. Before, the permit leaked in that case. Tests: new `ThreadPerTaskSedaConsumerStopTest`. A `ThreadPoolFactory` holds dispatched tasks until the stop reaches `awaitTermination`, so the test is deterministic. Without the fix, 0 messages are delivered instead of 1 (the exchange is rejected). Suites: 166 tests, 0 failures (2 pre-existing skips). Not changed here: a failed exchange in this consumer is reported to the exception handler twice. That's noted in the JIRA ticket for a separate change. Found with a TLA+ model of the thread-per-task consumer stop, then reproduced against the real classes. # 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). # 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 and tested the affected modules, including 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. -- 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]
