davsclaus opened a new pull request, #30553: URL: https://github.com/apache/camel/pull/30553
[CAMEL-27341](https://issues.apache.org/jira/browse/CAMEL-27341) With the test plugin installed, `camel dependency list`, `camel export` (and the new `camel dependency audit`, #30552) fail with exit code 70 in any directory that has a Citrus `test/` folder: ``` IllegalArgumentException: argument "in" is null at org.citrusframework.jbang.cli.util.CodeAnalyzer.getComponentDefinitions(CodeAnalyzer.java:167) ... at org.apache.camel.dsl.jbang.core.commands.test.TestPluginExporter.detectDependenciesFromTestSources(TestPluginExporter.java:214) ``` ## Cause The Citrus code analyzer (citrus-jbang 5.2.0) reads its catalog, `citrus-catalog/citrus/citrus-catalog-aggregate-*.json`, with the thread context class loader. The catalog is inside the citrus-jbang JAR, which is on the class loader of the plugin. During an export the context class loader is the CLI's, so `getResourceAsStream` returns null. `detectDependenciesFromTestSources` caught only `IOException`, so the `IllegalArgumentException` failed the whole command. ## Fix - `TestPluginExporter.detectDependenciesFromTestSources` sets the context class loader to the analyzer's class loader (the plugin's) while it scans, and restores it afterwards. - A test file that throws a `RuntimeException` while it is scanned is logged at WARN and skipped, so the command goes on without that file's test dependencies. ## Tests - New `TestPluginTest.shouldDetectDependenciesWhenTheContextClassLoaderCannotSeeCitrus`: it scans a Citrus YAML test with a context class loader that cannot see citrus-jbang, checks that `citrus-kafka` is detected, and checks that the context class loader is restored. Without the fix it fails with the same `argument "in" is null`. - All 18 tests of camel-jbang-plugin-test pass. - Not run by hand with an installed CLI: the original reproducer is `camel dependency list cve-audit.camel.yaml beans.yaml OrderNote.java application.properties` in `security/cve-audit` of apache/camel-jbang-examples#143 (CVE Audit example), which waits for this fix. _Claude Code on behalf of davsclaus_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
