Claus Ibsen created CAMEL-26930:
-----------------------------------
Summary: camel-jbang - camel run, dev and debug: background=true
in application.properties starts JVMs in a loop, flags lose to
application.properties, and a route that fails to start exits 70
Key: CAMEL-26930
URL: https://issues.apache.org/jira/browse/CAMEL-26930
Project: Camel
Issue Type: Bug
Components: camel-jbang
Reporter: Claus Ibsen
Fix For: 4.24.0
Found by a scan of the Camel CLI on 2026-11-13, with the unpacked
4.24.0-SNAPSHOT camel-launcher on macOS (JDK 25). *(exp)* means reproduced by
experiment, *(read)* means traced in the code. Paths are relative to
{{dsl/camel-jbang/}}, and line numbers are from main at that time. Earlier
findings of this kind: CAMEL-26901, CAMEL-26911 to CAMEL-26914.
h3. 1. camel.jbang.background=true in application.properties starts an endless
chain of JVMs (exp, high)
{{Run.java:1151}} reads the property. The parent removes {{--background}} from
the child's arguments, the child reads the same file, sees {{background=true}}
and starts its own child. In 12 s there were 19 chained JVMs and the routes
never started. {{camel.jbang.jvmDebug}} (line 1156) has the same shape. Mark
the child so it never goes to the background again.
h3. 2. Command-line flags lose to application.properties for most run options
(exp, high)
{{RunSettings.java:94}} {{write(...)}} takes the file's value first, and
{{RunProfileProperties.applyTo}} does {{request.stub =
properties.getProperty(STUB, request.stub)}} and similar
({{RunPipeline.configure}} lines 428-482 and 569-577, {{Run.java:1136-1142}}).
With {{camel.main.tracing=false}} in the file, {{--trace}} prints nothing; with
{{camel.jbang.console=false}}, {{--console}} gives 404. Affected: {{--trace}},
{{--backlog-trace}}, {{--dev}}, {{--console}}, {{--health}}, {{--metrics}},
{{--mcp}}, {{--openapi-ui}}, {{--stub}}, {{--modeline}},
{{--ignore-loading-error}}, {{--lazy-bean}}, {{--prompt}}, {{--gav}},
{{--open-api}}, {{--verbose}}, {{--jfr}}, {{--kamelets-version}},
{{--java-version}}, {{--camel-version}}, {{--maven-settings}},
{{--background}}, {{--jvm-debug}} and the logging options. CAMEL-24705 only
moved {{--max-*}} and {{--port}} to the override path; use it whenever the
option is given.
h3. 3. --jvm-debug, --jvm-args and --open-telemetry-agent re-run through jbang,
also under the launcher (exp, high)
{{Run.java:843}} ({{isDebugMode()}} -> {{runCamelVersion}}) and
{{createCamelVersionCommand}} (1207-1305) run {{jbang ... camel@apache/camel
run ...}}. Without jbang these options cannot work; with jbang the run uses
another Camel build (a remote SNAPSHOT, Kamelets 4.22.0 when 4.23.0 was asked
for) on jbang's JDK. {{--camel-version}} is refused under the launcher with a
clear message, these are not. Under the launcher, spawn
{{LauncherHelper.getCamelCommand()}} with the JVM options.
h3. 4. A route that fails to start exits 70, with its stack trace printed twice
(exp, high)
{{CliExecutionExceptionHandler}} maps any exception that is not a CLI exception
to 70, and {{KameletMainIntegration.start}} (79-88) rethrows the startup
failure. {{camel-jbang-exit-codes.adoc}} says 70 is "most often a bug in Camel
... do not retry", and 1 is "fix the route", so an AI agent gives up instead of
fixing its route. The 46-frame trace is printed on stdout (the log) and again
on stderr. Map startup failures from {{main.start()}} to exit 1 with one ERROR
line.
h3. 5. camel debug corrupts the arguments of the run it starts (exp)
{{Debug.removeDebugOnlyOptions}} (621-628) removes every argument that starts
with {{--}} plus the name of any Debug field: the field {{source}} also removes
{{--source-dir=...}}, and a space-separated value is left behind as a file
({{--breakpoint tick}} gives "File does not exist: tick", exit 66). Strip
options by exact name with their values, as
{{BackgroundWait.withoutBackgroundOptions}} does. There are no tests.
h3. 6. Dev mode reload (exp)
* The auto-detected {{application.properties}} is never reloaded:
{{RunPipeline.configure}} (609-614) adds {{./application.properties}}, which
neither the reload pattern nor {{PropertiesComponent.reloadProperties}}
matches. {{camel-jbang-running.adoc:242}} says it is reloaded.
* With files in two folders only the first file's folder is watched
({{RunPipeline.setupReload}} 1118-1131, {{CamelMainRunner.reloadArgs}} 249-262).
* {{--exclude}} is ignored for {{camel run .}}, {{--source-dir}} and {{camel
dev}} ({{file:<dir>/**}}, {{RunPipeline}} 749-760), and never matches a path
({{RunFiles.skipFile}} 152, 187). A regression since CAMEL-25349.
* {{camel dev > run.log}} in the project folder reloads all routes every 2 s:
{{sourceDirReloadPattern}} is {{*,!test/**}}. Reload only on source and
property files, and log which file triggered it.
h3. 7. Other run issues (exp)
* A child started for {{--jvm-args}}/{{--jvm-debug}} is orphaned when camel run
gets SIGTERM ({{Run.runCamelVersion}} 1197-1202, {{runCustomCamelVersion}}
1466-1471 wait with no shutdown hook); use {{ChildProcess.stopOnExit}}.
* {{camel run .}} with no loadable routes reports Running and exits 0
({{KameletMainIntegration.hasNoRoutes}} 163-170 skips the check with a source
dir); {{.yml}} is not a YAML DSL extension and nothing says so.
* An in-process {{run --background}} outside the launcher starts the {{camel}}
on PATH ({{LauncherHelper.getCamelCommand}}), which does not get the parent's
{{-Duser.home}}, so the child writes into the real {{~/.camel}}.
* (read) {{RunProfileProperties.java:88}} reads
{{application-<profile>.properties}} from the working directory, not the base
dir.
* (read) {{Run.loadFromClipboard}} writes {{<Class>.java}} into the working
directory, overwriting a file of that name.
* {{run --example --background}} leaves its temp folder after {{camel stop}}.
* (read) The runtime reads the working-directory
{{.camel-jbang/camel-jbang-run.properties}}
({{MainHttpServerFactory.java:52-57}}), so another run in the same folder can
change the HTTP port; extends CAMEL-26912 item 1.
h3. Missing tests
{{Debug.removeDebugOnlyOptions}}, flag versus properties precedence beyond
{{--max-*}}/{{--port}}, multi-folder and properties reload, {{--exclude}} with
a source dir.
_Claude Code on behalf of Claus Ibsen_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)