Croway opened a new pull request, #29990:
URL: https://github.com/apache/camel/pull/29990

   JIRA: [CAMEL-26964](https://issues.apache.org/jira/browse/CAMEL-26964), a 
follow-up of [CAMEL-26931](https://issues.apache.org/jira/browse/CAMEL-26931) 
(#29918).
   
   CAMEL-26931 made `camel run` and `camel export` go on without a stored 
plugin that cannot be loaded. Its catch in `PluginHelper.getActivePlugins` 
covers `RuntimeException` only, and a plugin built for another Camel version 
fails with a `LinkageError` instead. For example, a plugin built against 4.23 
refers to `org.apache.camel.dsl.jbang.core.common.Printer`, which moved to 
`org.apache.camel.dsl.jbang.run.common.Printer` in 4.24 (CAMEL-24724). 
`ObjectHelper.newInstance` catches `Exception` only, so the 
`NoClassDefFoundError` of the plugin's constructor lookup escapes and `camel 
run` fails. The same happens to the `camel_render_route_diagram` MCP tool, 
which runs the route in process.
   
   The cached path (`PluginHelper.loadFromCache`) already catches `Exception | 
LinkageError`; the factory-finder and download paths did not.
   
   ## Changes
   
   - `PluginHelper.getActivePlugins` also catches `LinkageError`:
     - for a plugin that contributes to `camel run` / `camel export`, the same 
warning as for other load failures, with the reason: `Plugin forage cannot be 
loaded (it does not link with Camel 4.24.0, it is likely built for another 
version: NoClassDefFoundError org/apache/camel/dsl/jbang/core/common/Printer), 
so camel run goes on without it: remove it with camel plugin delete forage`;
     - for the plugin's own command, a `CliException` with that reason ("update 
it, or remove it with camel plugin delete ...") instead of the raw error.
   - `PluginAdd`: the release check (`useRelease`) reports `Cannot load <gav>: 
<reason>` and leaves the configuration unchanged, and `resolves()` treats the 
error as a plugin that cannot be loaded, instead of failing `camel plugin add`.
   - `camel-jbang-projects.adoc`: the paragraph of CAMEL-26931 says that this 
includes a plugin built for another Camel version.
   
   ## Tests
   
   - `PluginHelperTest.aPluginThatDoesNotLinkDoesNotFailCamelRun`: a plugin on 
the test classpath (a new test-only 
`META-INF/services/.../camel-jbang-plugin-unlinked` for the existing 
`UnlinkedFakePlugin`) whose creation fails with a `NoClassDefFoundError`: 
`camel run` warns and goes on, its own command fails with the reason.
   - `PluginAddTest.shouldNotChangeConfigWhenSelectedReleaseDoesNotLink`: a 
release whose download fails with a `NoClassDefFoundError`.
   - Both fail without the fix with the `NoClassDefFoundError`. 
`PluginHelperTest`, `PluginAddTest` and `PluginFilteringTest`: 86 tests green. 
Whole camel-jbang-core module locally: 3092 tests, one error in 
`JbangDevMcpServerTest` (`NoSuchMethodError` in the JSON Schema validator, from 
an outdated local `camel-mcp-server` snapshot), unrelated to this change.
   
   _Claude Code on behalf of Croway_
   


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