[
https://issues.apache.org/jira/browse/CAMEL-26913?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Work on CAMEL-26913 started by Guillaume Nodet.
-----------------------------------------------
> camel-jbang - CLI startup and config: a malformed config file breaks every
> command, the plugin config can be wiped, CDS archives are shared between
> installs, and --version resolves all plugins
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-26913
> URL: https://issues.apache.org/jira/browse/CAMEL-26913
> Project: Camel
> Issue Type: Bug
> Components: camel-jbang
> Reporter: Claus Ibsen
> Assignee: Guillaume Nodet
> Priority: Major
> Fix For: 4.24.0
>
>
> Found by an analysis of the Camel CLI on the night of 2026-11-12, with the
> unpacked 4.24.0-SNAPSHOT camel-launcher on macOS. *(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. Dependency
> resolution of camel run is covered separately by CAMEL-26901.
> h3. 1. A malformed ~/.camel-cli.properties breaks every command, including
> camel config (exp)
> {{CommandLineHelper}} (around lines 131-137 and 167-172) catches only
> {{IOException}}. A line such as {{path=C:\users\name}} throws "Malformed
> \uxxxx encoding" from {{Properties.load}}, and every command fails, including
> {{camel config}}, which the user would need to fix it. It should warn and
> skip the file (or the bad line).
> h3. 2. The plugin config ~/.camel-jbang-plugins.json is fragile and can be
> wiped (exp)
> * An empty JSON object causes an NPE for {{camel run}} and {{camel --help}}.
> * A truncated file means "no plugins", and the next {{camel plugin add}}
> overwrites it, so the other entries are lost.
> * Writes truncate and then write, with no atomic move, and they also happen
> implicitly when the {{resolved}} cache is written, so two commands at once
> can tear it.
> h3. 3. A CDS archive from another install of the same version runs the other
> install's JAR (exp)
> {{camel.sh}} keeps the archive at
> {{$XDG_CACHE_HOME/camel-cli/cds/<version>/<cmd>.jsa}}, without the install
> directory. With two installs of the same version side by side (SDKMAN,
> Homebrew, web installer, zip, nightly) or a moved install:
> * child processes ({{camel run --background}}) start the other install's JAR
> * {{InstallDetector}} detects the wrong install method, which affects {{camel
> self-update}} and the update notice
> * the update check is skipped
> The install directory (or a hash of it) should be part of the path.
> h3. 4. --version, --help, camel and typos build the full tree and resolve
> every plugin (exp)
> One unresolvable plugin makes {{camel --version}} exit 1 after contacting
> Maven Central, and scripts and installers use it as a check. {{camel
> --version}}: 0.28s and 4,390 classes vs {{camel version}}: 0.13s and 1,807
> classes.
> h3. 5. run, export and cmd load all embedded plugins (exp)
> {{PLUGIN_CONSUMING_BUILTINS}} in {{CamelLauncherMain}} includes {{cmd}}, but
> no plugin adds to {{cmd}}. {{camel cmd send --help}}: 0.35-0.42s and 4,743
> classes vs {{camel get route}}: 0.18s and 2,147. The TUI and the AI tools
> call {{cmd}} a lot.
> h3. 6. Deferred log4j setup (CAMEL-26429) is undone by static slf4j loggers
> (exp)
> Static loggers such as camel-util {{IOHelper}} bind log4j early, and
> {{log4j2.disable.jmx=false}}. Without the binding, {{camel doc kafka}} goes
> from 0.25s to 0.18s (-28%) and from 3,471 to 2,067 classes.
> h3. 7. Every distinct first word creates a ~30 MB CDS archive, never pruned
> (exp)
> {{camel.sh}} uses {{_cds_cmd="$1"}}, typos included, and old version
> directories stay. A developer {{~/.cache/camel-cli}} was 151 MB for one
> version, {{export.jsa}} alone 72 MB. Only known commands should get an
> archive, and other versions' directories should be pruned.
> h3. 8. camel catalog component parses all 421 component JSONs (13 MB) even
> with --filter (exp)
> 0.47s vs 0.25s for {{camel doc kafka}}.
> h3. 9. The TUI and camel ask tools have no catalog cache (read)
> {{ToolContext}} is new per call; for another Camel version each call goes
> through {{CatalogLoader}}, a new resolver and a classloader that is never
> closed. The MCP server already caches in {{CatalogService}}.
> h3. 10. Smaller (exp)
> * The embedded plugin scan stops at the first JAR
> ({{PluginHelper.addEmbeddedPlugins}} has a {{break}}).
> * {{mcp}} is missing from {{CamelLauncherMain.PLUGINS}}, so the first {{camel
> mcp}} "installs" it.
> * {{camel version}} prints "JBang version: 0.143.0" under the launcher.
> h3. Came out clean
> The update check is a daemon thread with at most 2s once a day; CDS creation
> is safe under 8 parallel first runs; plugin cache validation is cheap.
> h3. Suggested order
> # 1, 2, 3 (a broken or wrong CLI)
> # 4 (scripts check --version)
> # 5, 6, 7 (speed and disk), then the rest
> _Claude Code on behalf of Claus Ibsen (davsclaus)_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)