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

   # Description
   
   [CAMEL-27086](https://issues.apache.org/jira/browse/CAMEL-27086)
   
   `ZooKeeperConsumer.doStop` set `shuttingDown` and nothing reset it. When the 
same consumer object was started again, `initializeConsumer()` added no 
operation, so the new operations thread waited for ever on an empty queue and 
the route received nothing more, with no error.
   
   The same consumer object is started again by a route policy that stops and 
starts the consumer of its route (`ZooKeeperConsumer` is not `Suspendable`, so 
`ThrottlingInflightRoutePolicy` and the circuit breaker 
`ThrottlingExceptionRoutePolicy` stop and start it through 
`RoutePolicySupport`), and by JMX `ManagedConsumer` stop/start. A route stop 
and start through the route controller creates a new consumer and was not 
affected.
   
   The stop also left the operations thread of that start running: 
`ExecutorServiceManager.shutdown` does not interrupt it, so it stayed blocked 
on the queue or on the watch of the closed connection, and after a start it 
could take operations of the new sequence.
   
   Fix, in `ZooKeeperConsumer`:
   - `doStart` clears `shuttingDown`;
   - `doStop` stops the `OperationsExecutor` of that start: it is marked 
stopped and its thread interrupted, unless the stop runs on that thread (a 
route policy can stop the consumer when an exchange is done, on the operations 
thread), in which case it ends when the exchange returns;
   - a stopped `OperationsExecutor` does not offer a copy of its operation, 
does not start the sequence again, and does not report the interrupt of the 
stop as an error; when it gets a connection while it is being stopped it closes 
it only if the consumer is not running again (it would be the connection of the 
new start).
   
   Tests: `ZooKeeperConsumerRestartTest` (embedded `ZooKeeperServer`, as 
`ZooKeeperConsumerSessionExpiryTest`): after the first data, 
`ServiceHelper.stopService(consumer)` and `startService(consumer)`; the 
consumer must read the node again, have one operations thread, and consume an 
update made through its session once it waits for a change. Without the change 
it never reads the node again (fails after 20 seconds). With the change the 
camel-zookeeper unit tests pass (30 run, 0 failures), and the new test passes 
20 times in one JVM.
   
   # 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-27086](https://issues.apache.org/jira/browse/CAMEL-27086).
   
   # 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 and camel-zookeeper 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]

Reply via email to