Claus Ibsen created CAMEL-27341:
-----------------------------------

             Summary: camel-jbang - camel dependency list and camel export fail 
with the test plugin in a directory with Citrus tests
                 Key: CAMEL-27341
                 URL: https://issues.apache.org/jira/browse/CAMEL-27341
             Project: Camel
          Issue Type: Bug
          Components: camel-jbang
            Reporter: Claus Ibsen
             Fix For: 4.24.0


With the test plugin installed (its exporter applies to export), {{camel 
dependency list}} (and {{camel export}}, {{camel dependency audit}}) fails in a 
directory that has a {{test/}} folder with Citrus tests:

{noformat}
ERROR: argument "in" is null
java.lang.IllegalArgumentException: argument "in" is null
        at tools.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:1144)
        at 
org.citrusframework.jbang.cli.util.CodeAnalyzer.getComponentDefinitions(CodeAnalyzer.java:167)
        at 
org.citrusframework.jbang.cli.util.CodeAnalyzer.getKnownInfraServices(CodeAnalyzer.java:161)
        ...
        at 
org.apache.camel.dsl.jbang.core.commands.test.TestPluginExporter.detectDependenciesFromTestSources(TestPluginExporter.java:214)
{noformat}

Exit code 70. Seen with the 4.24.0-SNAPSHOT CLI and citrus-jbang 5.2.0, e.g. in 
{{security/cve-audit}} of camel-jbang-examples.

Cause: {{CodeAnalyzer}} reads 
{{citrus-catalog/citrus/citrus-catalog-aggregate-infra-services.json}} with 
{{ClassLoaderHelper.getClassLoader()}}, which is the thread context class 
loader. The resource is in the citrus-jbang JAR, which is on the class loader 
of the plugin, but during an export the context class loader is the one of the 
CLI, so the stream is null. 
{{TestPluginExporter.detectDependenciesFromTestSources}} catches only 
{{IOException}}, so the {{IllegalArgumentException}} fails the whole command.

Fix in Camel: set the context class loader to the one of the plugin 
({{CodeAnalyzer.class.getClassLoader()}}) while scanning, and catch a runtime 
exception of the analyzer per file (log it, go on without the test dependencies 
of that file). Citrus could also look up its own catalog with the class loader 
of its classes.

_Claude Code on behalf of Claus Ibsen_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to