davsclaus opened a new pull request, #29114: URL: https://github.com/apache/camel/pull/29114
## Summary [CAMEL-26554](https://issues.apache.org/jira/browse/CAMEL-26554): when the last consumer on a port is stopped and stopping its Jetty connector or server throws, the entry stayed in the static `CONNECTORS` map with a closed socket. The next consumer on that port reused it ("Using existing connector key"): its route reported Started, but the port refused connections until the JVM was restarted. The reporter hit it when a route group shutdown timed out: the cancelled shutdown task stopped the jetty consumer on an interrupted thread, and Jetty's `ManagedSelector.doStop` threw `InterruptedException` from `Server.removeConnector`. The core side of that is a separate issue (the cancelled task should not stop consumers at all), this PR makes camel-jetty robust against any failed stop. ## Changes - `JettyHttpComponent.disconnect`: when the ref count reaches 0 the connector is always removed from `CONNECTORS`. The stop failure is kept and thrown after the `computeIfPresent`, so the caller still sees it. - New `stopConnector(ConnectorRef)`: removes the connector from the server, stops the connector, the server, the MBean and the thread pool, each one even when an earlier one fails (first failure thrown, later ones suppressed). Before, a failing `removeConnector` skipped `server.stop()` and the thread pool. - `doStop` uses the same helper and logs a failure instead of stopping halfway through the connectors. It also no longer calls `removeServerMBean` when there is no MBean container (that would have been an NPE). I did not add the second suggestion from the JIRA (do not reuse a `ConnectorRef` whose server is not running in `connect`): with the entry always removed there is no stale entry left to find, and replacing a ref that other consumers still count on would break their later `disconnect`. ## Tests - New `JettyConsumerStopFailedTest`: stops the only consumer on a port on an interrupted thread, checks the connector is gone, then starts a new route on the same port and calls it. Fails without the fix ("the connector of the stopped consumer is still registered"). - `camel-jetty`: 422 tests, 0 failures. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_0128ThHB3iQdrvSRLVBGRrdP -- 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]
