oscerd opened a new pull request, #28974: URL: https://github.com/apache/camel/pull/28974
Fixes [CAMEL-26220](https://issues.apache.org/jira/browse/CAMEL-26220), found while adding the catalog body types (CAMEL-24961). ## 1. query always fails with NoClassDefFoundError for Gson $Gson$Types **Was:** camel-parent manages Gson at 2.15.0 (2.14.0 when the issue was filed). The IBM Watson SDK 16.2.0 brings `com.ibm.cloud:sdk-core` 9.20.0, and the watsonx.data SDK 0.9.0 brings 9.18.4. Their `DynamicModelTypeAdapterFactory` uses the Gson internal class `com.google.gson.internal.$Gson$Types`, which Gson 2.13.0 renamed to `GsonTypes`. So the SDK failed to parse every response whose model holds a class with dynamic properties. For the `query` operation that is `QueryResult` inside `QueryResponse`, so every query failed, even one answered with `{"matching_results":0}`, with `InvalidServiceResponseException: Error processing the HTTP response` caused by `NoClassDefFoundError: com/google/gson/internal/$Gson$Types`. The other operations of the component were not affected: `QueryResult` and `AnalyzedResult` (of `analyzeDocument`, which the component does not call) are the only such models of the Discovery SDK. **Now:** `camel-ibm-parent` manages `com.ibm.cloud:sdk-core` at the new `ibm-sdk-core-version` property of `parent/pom.xml`, 9.24.3, which uses `GsonTypes`. Every camel-ibm module that uses sdk-core (watson-discovery, watson-language, watson-speech-to-text, watson-text-to-speech, watsonx-data and secrets-manager) now builds and tests with it. camel-ibm-watson-discovery also declares `sdk-core` (with the managed version) next to the Watson SDK, so that applications get 9.24.3 too: Maven applies the dependency management of camel-ibm-parent when it builds Camel, but not when it resolves the dependencies of an application that uses the component. Checked with Maven 3.9 on an application that depends on the component: with the management only it still gets sdk-core 9.20.0, and with a Gson of 2.13 or later (Spring Boot 4.1 manages 2.13.2) that is the failing combination; with the declared dependency it gets 9.24.3. The version: sdk-core 9.23.1 is the first release that uses `GsonTypes` (it moved to Gson 2.13.0; 9.23.0 and older use `$Gson$Types`). 9.24.3 is the last release on OkHttp 4 (4.12.0, what the modules use today); 9.25.0 moved to OkHttp 5, and sdk-core is tied to the OkHttp major version it is built with (9.24.x calls `okhttp3.internal.Util`, which OkHttp 5 removed, and 9.25.0 and later call `okhttp3.internal._UtilCommonKt`, which OkHttp 4 does not have). The IBM SDKs the modules use are built with OkHttp 4, and there is no newer release of them that brings a fixed sdk-core: Watson 16.2.0 and watsonx.data 0.9.0 are the latest. Every sdk-core method and field the IBM SDK jars of the modules call exists in 9.24.3, and the Gson internal methods 9.24.3 calls exist in Gson 2.15.0. What the modules resolve, before and after: - watson-discovery, watson-language, watson-speech-to-text, watson-text-to-speech: sdk-core 9.20.0 to 9.24.3, kotlin-stdlib 1.9.10 to 1.9.25; OkHttp 4.12.0 and Gson 2.15.0 unchanged. - watsonx-data: sdk-core 9.18.4 to 9.24.3, OkHttp 4.11.0 to 4.12.0, Okio 3.2.0 to 3.6.0, kotlin-stdlib 1.6.21 to 1.9.25. - secrets-manager: sdk-core 9.23.1 to 9.24.3. - cos and watsonx-ai do not use sdk-core. ## Tests - New `WatsonDiscoveryProducerQueryTest` (2 tests), with a JDK `HttpServer` as the Discovery service and as the IAM token service: a query answered with `{"matching_results":0}`, and a query whose result has a property the model does not declare (`title`, kept as a dynamic property), checking the request sent (`natural_language_query`, the `version` parameter and the bearer token). - With the `pom.xml` changes reverted, both new tests fail with `InvalidServiceResponseException` caused by `NoClassDefFoundError: com/google/gson/internal/$Gson$Types`. - Module tests with sdk-core 9.24.3, 0 failures in each: watson-discovery 6 (4 existing and the 2 new), secrets-manager 6, watson-language 4, watson-text-to-speech 5, watson-speech-to-text 5, watsonx-data 9. ## Docs and generated files - No change to the component doc or the body types: they describe the query as it works with the fix. - The new property `ibm-sdk-core-version` of `parent/pom.xml` goes into the generated camel-dependencies pom. - No upgrade guide entry: the query never worked with the Gson of Camel, and an application does not need to change anything. ## Not changed - Only camel-ibm-watson-discovery (here) and camel-ibm-watsonx-data (CAMEL-26221) declare `sdk-core` themselves, as only their operations failed. watson-language, watson-speech-to-text and watson-text-to-speech have no model with dynamic properties, and secrets-manager 2.0.28 already brings sdk-core 9.23.1, so applications that use them are not affected by the older sdk-core they get. Declaring it there as well would give them the same version as the Camel build. - sdk-core 9.29.1 (with OkHttp 5.5.0) is the latest release. Moving to it means moving the IBM SDKs, which are built with OkHttp 4, to OkHttp 5: that is a separate upgrade. Main only for now, as the other fixes of the CAMEL-24961 follow-ups. The query fails the same way on camel-4.22.x (Gson 2.14.0) and camel-4.18.x (Gson 2.13.2), which use the same Watson SDK 16.2.0, so a backport could follow if wanted. _Claude Code on behalf of Andrea Cosentino (oscerd)_ 🤖 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]
