[ 
https://issues.apache.org/jira/browse/CAMEL-26926?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Luigi De Masi reassigned CAMEL-26926:
-------------------------------------

    Assignee: Luigi De Masi

> camel-jbang: Spring Boot/Quarkus catalogs mix requested and server versions
> ---------------------------------------------------------------------------
>
>                 Key: CAMEL-26926
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26926
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-jbang, camel-jbang-mcp
>    Affects Versions: 4.22.1, 4.24.0
>            Reporter: Luigi De Masi
>            Assignee: Luigi De Masi
>            Priority: Major
>
> h2. Problem
> The shared JBang catalog loaders for Spring Boot and Quarkus retain the 
> running server's catalog version manager and resolve generic catalog 
> resources from the server classpath. A request targeting an older Camel 
> version can therefore report the server version and combine target-runtime 
> component metadata with newer EIP/model metadata.
> Reproduced in Camel MCP 4.24.0-SNAPSHOT using both the latest published 
> snapshot available at the check, 4.24.0-20261112.143700-31, and a locally 
> installed snapshot. Main correctly resolves the tested 4.8.0 target. The 
> Spring Boot problem was also reproduced with the released 4.22.1 MCP runner.
> h2. Reproduction on 4.24.0-SNAPSHOT
> Run the [published MCP 
> runner|https://repository.apache.org/content/repositories/snapshots/org/apache/camel/camel-jbang-mcp/4.24.0-SNAPSHOT/camel-jbang-mcp-4.24.0-20261112.143700-31-runner.jar]
>  on Java 21 and connect an MCP client. For example:
> {code:bash}
> java -Dquarkus.log.level=WARN -Dquarkus.http.port=-1 \
>   -jar camel-jbang-mcp-4.24.0-20261112.143700-31-runner.jar
> {code}
> Call {{camel_configuration_validate}} with:
> {code:json}
> {
>   "runtime": "spring-boot",
>   "camelVersion": "4.8.0",
>   "properties": "camel.component.http.max-total-connections=20"
> }
> {code}
> Actual response, omitting the property-detail array:
> {code:json}
> {
>   "camelVersion": "4.24.0-SNAPSHOT",
>   "summary": {
>     "total": 1,
>     "valid": 1,
>     "errors": 0,
>     "warnings": 0,
>     "unchecked": 0
>   }
> }
> {code}
> Adding 
> {{platformBom=org.apache.camel.springboot:camel-spring-boot-bom:4.8.0}} gives 
> the same result.
> For Quarkus, call the same tool with:
> {code:json}
> {
>   "runtime": "quarkus",
>   "platformBom": "io.quarkus.platform:quarkus-camel-bom:3.15.1",
>   "properties": "camel.component.http.max-total-connections=20"
> }
> {code}
> That [published 
> BOM|https://repo.maven.apache.org/maven2/io/quarkus/platform/quarkus-camel-bom/3.15.1/quarkus-camel-bom-3.15.1.pom]
>  selects Camel core 4.8.0 and Camel Quarkus catalog 3.15.0. The response 
> again reports {{camelVersion=4.24.0-SNAPSHOT}}.
> Control: the first request with {{runtime=main}} returns 
> {{camelVersion=4.8.0}}. Repeating the Spring Boot and Quarkus requests after 
> the Main request reproduces the mismatch; it does not require a stale MCP 
> process or a cross-version cache collision.
> h2. Expected behavior
> The reported Camel version and all version-specific catalog resources should 
> correspond to the selected target core catalog. Runtime-specific Maven 
> coordinates should continue to use the selected Spring Boot or Camel Quarkus 
> provider version. A missing target schema should not silently resolve to a 
> newer server schema.
> h2. Actual resource mixing
> Byte comparisons of schemas returned by the loaded catalogs established:
> || Runtime and target || Runtime-specific schemas || EIP/model schemas || 
> Reported version ||
> | Main / Camel 4.8.0 | Match the 4.8.0 catalog | All 235 match the 4.8.0 
> catalog | 4.8.0 |
> | Spring Boot / Camel 4.8.0 | All 352 components, 46 data formats and 26 
> languages match the 4.8.0 provider | All 241 match the local 4.24.0-SNAPSHOT 
> runner | 4.24.0-SNAPSHOT |
> | Quarkus platform 3.15.1 / Camel 4.8.0 | All 301 components, 45 data formats 
> and 24 languages match the Camel Quarkus 3.15.0 provider | All 241 match the 
> local 4.24.0-SNAPSHOT runner | 4.24.0-SNAPSHOT |
> For example, the mixed catalog exposes {{split.errorThreshold}}, which is 
> absent from the 4.8.0 split model. HTTP dependency coordinates remain 
> correctly target-specific: {{camel-http-starter:4.8.0}} and 
> {{camel-quarkus-http:3.15.0}}. Thus correct dependency coordinates do not 
> establish that the entire catalog uses the requested version.
> This can mislead version-specific authoring or validation. It is not 
> sufficient to change only the version string returned by the MCP tool.
> h2. Root cause and scope
> Inspected main at {{ea617cb1634c3d95c3edd3a1d2021086583e341f}} and compiled 
> the four relevant production sources unchanged for focused loader probes 
> against the local snapshot runner.
> * 
> [CatalogLoader|https://github.com/apache/camel/blob/ea617cb1634c3d95c3edd3a1d2021086583e341f/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/CatalogLoader.java]:
>  {{loadSpringBootCatalog}} and {{loadQuarkusCatalog}} use downloader 
> classloaders with a parent. Catalog classes already present in the parent are 
> reused. Both retain {{DefaultVersionManager}} and only change its resource 
> classloader.
> * 
> [DefaultVersionManager|https://github.com/apache/camel/blob/ea617cb1634c3d95c3edd3a1d2021086583e341f/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/DefaultVersionManager.java]:
>  changing its classloader does not change the {{VersionHelper}} used by 
> {{getLoadedVersion()}}. Resource lookup also falls back to the server 
> classloader if the configured loader returns null.
> * 
> [VersionHelper|https://github.com/apache/camel/blob/ea617cb1634c3d95c3edd3a1d2021086583e341f/catalog/camel-catalog/src/main/java/org/apache/camel/catalog/VersionHelper.java]:
>  reads version metadata through its own defining class. In the packaged 
> runner it reads the server's {{META-INF/version.properties}}.
> * Runtime-specific resource namespaces reach the downloaded providers, while 
> generic EIP/model paths resolve in the parent first. Main uses an isolated 
> resource loader and {{DownloadCatalogVersionManager}}, and passed the tested 
> 4.8.0 case.
> The 4.24 snapshot has replaced the old 
> {{camel_catalog_components/component_doc/component_maven}} API with generic 
> {{camel_catalog_find/doc}} tools. Those new authoring tools do not accept 
> {{runtime}}/{{platformBom}}, and their generic 4.8.0 lookups passed. The 
> public reproduction above uses the still-supported runtime-aware 
> {{camel_configuration_validate}} tool. The defect is in the shared runtime 
> loader, not every catalog tool.
> Related earlier fixes: CAMEL-23186, CAMEL-23190 and CAMEL-23197. This report 
> isolates the remaining Spring Boot and Quarkus loader paths.
> h2. Regression coverage
> * Cover Main, Spring Boot and Quarkus with a resolvable target older than the 
> running catalog.
> * Assert the resolved core version, target-specific provider coordinates and 
> actual schema content, including a field present only in the newer server 
> catalog.
> * Assert that a schema absent from the target catalog does not fall back to 
> the server catalog.
> * Cover Spring Boot requests with and without a matching BOM, Quarkus with a 
> verified explicit BOM, and repeated mixed-version requests.
> * Preserve compatible provider class loading while isolating version-specific 
> resource lookup; replacing only the response version must not make the 
> regression pass.
> Validation completed: 22 diagnostic MCP cases across the published and local 
> snapshot runners, focused unchanged-source loader probes, and full byte 
> comparisons for the schema categories above. No production fix or full Maven 
> reactor build was performed as part of this investigation.
> _AI-generated by Codex on behalf of @luigidemasi._



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

Reply via email to