Claus Ibsen created CAMEL-24388:
-----------------------------------
Summary: Camel JBang - PluginHelper should guard against duplicate
subcommand registration
Key: CAMEL-24388
URL: https://issues.apache.org/jira/browse/CAMEL-24388
Project: Camel
Issue Type: Bug
Components: camel-jbang
Reporter: Claus Ibsen
When upgrading the Camel CLI (e.g. from 4.20 to 4.22), the old
~/.camel-jbang-plugins.json file may still list plugins that are now bundled as
embedded plugins in the fat-jar. This causes picocli to throw a
DuplicateNameException because the same subcommand name (e.g. "tui") gets
registered twice - once from the embedded classpath plugin and once from the
JSON config.
Stack trace:
{code}
Caused by: picocli.CommandLine$DuplicateNameException: Another subcommand named
'tui' already exists for command 'camel'
at
picocli.CommandLine$Model$CommandSpec.addSubcommand(CommandLine.java:6587)
at picocli.CommandLine.addSubcommand(CommandLine.java:378)
at picocli.CommandLine.addSubcommand(CommandLine.java:357)
at
org.apache.camel.dsl.jbang.core.commands.tui.TuiPlugin.customize(TuiPlugin.java:39)
at
org.apache.camel.dsl.jbang.core.common.PluginHelper.addPlugins(PluginHelper.java:178)
{code}
The workaround is to delete ~/.camel-jbang-plugins.json, but PluginHelper
should guard against this generically for all plugins.
The fix should:
1. Make the existing containsKey guard at PluginHelper line 174 unconditional
(remove the foundEmbeddedPlugins && prefix) so JSON-config plugins are always
skipped if the command name is already registered.
2. Add a similar guard in loadPluginFromService() (line 759) before calling
plugin.customize(), so embedded plugins also skip if the command is already
registered.
This protects all plugins, not just TUI.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)