davsclaus opened a new pull request, #28762: URL: https://github.com/apache/camel/pull/28762
_Claude Code on behalf of davsclaus_ Fixes [CAMEL-26427](https://issues.apache.org/jira/browse/CAMEL-26427), found while measuring the startup of the CLI for [CAMEL-23810](https://issues.apache.org/jira/browse/CAMEL-23810). Every command of the CLI (`camel version`, `camel ps`, `camel --help`, ...) waited about 300 ms before the JVM exited. `Harden` created its JDK `HttpClient` in a field initializer, and the CLI creates all its commands at startup, so every run started the selector thread of that client. The thread is in native code (`KQueue.poll` / `epoll`) when the JVM exits, and HotSpot waits up to 300 ms for such threads before it exits. ## Changes - `Harden` creates its HTTP client on first use. ## Measured `camel version` on JDK 25 (Apple M4 Pro), with the classes of the launcher on a flat classpath, as JBang runs the CLI: | | before | after | | --- | --- | --- | | from the start to `System.exit` | 605 ms | 561 ms | | from `System.exit` to the end of the process | 313 ms | 5 ms | | wall | about 920 ms | 566 ms | `camel --help` and `camel ps` are the same. ## Tests - `CamelJBangMainTest.creatingTheCommandsStartsNoThread` (new): creating the commands of the CLI starts no thread. It fails without the fix (`HttpClient-1-SelectorManager`). - `HardenTest`, `CamelJBangMainTest`, `CliRunnerTest` pass. - With the embedded plugins of the launcher (TUI, Kubernetes, test, validate, generate, self-update), no thread is left either. 🤖 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]
