davsclaus opened a new pull request, #27933: URL: https://github.com/apache/camel/pull/27933
Step 12 of [CAMEL-25388](https://issues.apache.org/jira/browse/CAMEL-25388), the first part of the tech debt cleanup: the copies that carried the same bug in several places. ### ChildProcess: the child processes stop with the CLI - `ChildProcess.stopOnExit(process, cleanup)` replaces the 8 copies of the shutdown hook that stops the Maven process of `camel run` (Spring Boot, Quarkus, Camel Main export, an existing Maven project) and of `camel debug` (Spring Boot, Quarkus), and then removes the files of the run. - It stops the processes Maven started as well: `spring-boot:run` and `quarkus:dev` run the app in a JVM of their own, which could outlive Maven. What has not stopped after 30 seconds is killed; the hooks waited 30 seconds and then left it running. - The replacement was mechanical: one pattern matched exactly these 8 hooks, and each cleanup is unchanged. The two other hooks of `Run`/`Debug` are different (one is removed again after the process ends, one stops the debugged process on exit) and stay as they are. ### MavenCommand: one lookup of the Maven wrapper - `MavenCommand.of(dir)` (the wrapper of the project when it can run, else `mvn`) and `MavenCommand.wrapper(dir)` replace the 10 lookups of `mvnw` / `mvnw.cmd` in `camel run`, `camel debug` and `camel kubernetes run`. ### Plugin loading does not exit the JVM - A plugin that cannot be loaded (not found, or with a first version newer than the Camel version) throws a `CliException` (exit code 1) instead of `main.quit(1)`, which is `System.exit` in the middle of the plugin loading, and ended a program that embeds the CLI. `CamelJBangMain` prints the error and ends the command with the exit code, as before. ### Not in this PR (stays open on the JIRA) - The listing boilerplate (`sortRow` and `Row.copy()` in each listing, the since/throughput/short-URI helpers). - The other duplicates (`loadCatalog`, `doExport`, Maven invocation); the Kamelet catalog loader of `camel catalog kamelet` is shared since CAMEL-25399. - The embedding blockers besides `System.exit`: logging initialized once, the shared `.camel-jbang` work directory, fields that are not options keeping their values when the command tree is reused. - Splitting `Run.java` and moving `harden` onto `LlmClient`: that comes with the run/export split (CAMEL-24724 and others), as agreed for this work. ### Docs - 4.24 upgrade guide: "processes started by the CLI stop with it". ### Tests - `ChildProcessTest`: a process and the process it started both stop, a process that ignores SIGTERM is killed after the time, the Maven wrapper of a project or `mvn` (a wrapper that cannot run is not used). - `PluginHelperTest`: the plugin that is not found and the version check expect the `CliException` instead of a call to `quit`. - `mvn test` of camel-jbang-core and camel-jbang-plugin-kubernetes: all tests pass. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DDRLJAyf8cDXSg8iX785My -- 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]
