hansva opened a new issue, #9542:
URL: https://github.com/apache/hop/issues/9542

   ### Apache Hop version?
   
   2.20.0
   
   ### Java version?
   
   21
   
   ### Operating system
   
   Other
   
   ### What happened?
   
   Hop's command line tools (`hop-conf`, `hop-run`, `hop-search`, `hop-import`, 
`hop-server`, the `hop` launcher and the GUI) get their extra command line 
options from configuration plugins. `Hop.addMixinPlugins` goes over every 
config plugin of the command's category, loads its class and adds it to the 
picocli command as a mixin:
   
       IConfigOptions configOptions =
           PluginRegistry.getInstance().loadClass(configPlugin, 
IConfigOptions.class);
       cmd.addMixin(configPlugin.getIds()[0], configOptions);
   
   None of these calls is guarded per plugin. When one plugin fails, the 
exception leaves `addMixinPlugins` and the whole command stops before it parses 
any arguments. That includes the plugins that have nothing to do with the 
problem, such as `projects`.
   
   A config plugin can fail here when:
   
   - its class or one of its dependencies is missing or can't be linked 
(`HopPluginException`, or a `NoClassDefFoundError`/`LinkageError`, for example 
a plugin built against another Hop version or one that needs SWT on a headless 
install);
   - its static initialisation or constructor throws;
   - picocli refuses the mixin, for example because two plugins declare the 
same option name.
   
   Because the `hop` launcher loads the root-category plugins for every 
subcommand (`Hop.java`, `addMixinPlugins(hop.cmd, 
ConfigPlugin.CATEGORY_ROOT)`), one broken plugin in that category stops every 
Hop command. In practice, one bad third-party or half-installed plugin in 
`plugins/` leaves Hop with no command line until that plugin is removed. Often 
the error doesn't say which plugin caused it, and `hop-conf` itself can't be 
used to fix the configuration.
   
   ### Expected
   
   A config plugin that can't be loaded or added is skipped. Hop logs one error 
line that names the plugin id and the reason, and the command carries on with 
the other plugins. Its options are then simply unavailable. If the user passes 
one of them, picocli reports an unknown option, which also points at the plugin.
   
   ### Proposed fix
   
   In `Hop.addMixinPlugins`, wrap the load and the `addMixin` of each plugin in 
its own try/catch. Catch `Exception` and `LinkageError`, so a missing class is 
covered as well. Log the plugin id and the cause through `LogChannel.GENERAL`, 
then continue with the next plugin. The method signature doesn't change.
   
   ### Tests
   
   - A unit test with a registered config plugin whose class can't be loaded, 
next to a working one in the same category. The command still builds, the 
working plugin's option still parses, and the broken plugin is reported by id.
   - The same with two plugins that declare the same option name: the second 
one is skipped, not the command.
   
   ### Issue Priority
   
   Priority: 2
   
   ### Issue Component
   
   Component: CLI


-- 
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]

Reply via email to