oscerd opened a new pull request, #28563: URL: https://github.com/apache/camel/pull/28563
Jira: https://issues.apache.org/jira/browse/CAMEL-26343 ### Problem Since CAMEL-23866 (4.22.0), `AwsClientBuilderUtil` sets an HTTP client on the AWS SDK client builder only when a proxy or `trustAllCertificates` is configured. Otherwise the AWS SDK looks the HTTP client up with `ServiceLoader`. `ClasspathSdkHttpServiceProvider` loads every registered `SdkHttpService` before ranking them, so one registration that cannot be loaded fails the whole lookup with `ServiceConfigurationError`, even though the `Apache5SdkHttpService` that Camel ships is there. This breaks the AWS connectors of Camel Kafka Connector 4.22.0 on `confluentinc/cp-kafka-connect:8.2.4` (apache/camel-kafka-connector#1849). The worker classpath has its own AWS SDK with the classic `apache-client`. The plugin class loader also returns the worker's `META-INF/services` files, so `ApacheSdkHttpService`, which the plugin no longer ships, is loaded from the worker: `software.amazon.awssdk.http.apache.ApacheSdkHttpService not a subtype`. ### Change - When no proxy is configured, `AwsClientBuilderUtil.buildClient` sets `Apache5HttpClient.builder()` and `buildAsyncClient` sets `NettyNioAsyncHttpClient.builder()`. These are the implementations the SDK lookup selects from Camel's dependencies. The SDK builds them with the same service defaults (`buildWithDefaults`) and closes them with the client, as it does for the client it looks up, so a working setup behaves as before. - When the AWS SDK setting `software.amazon.awssdk.http.service.impl` (or `software.amazon.awssdk.http.async.service.impl`) names an implementation, Camel still leaves the choice to the SDK. - The proxy and `trustAllCertificates` paths are unchanged. - Upgrade-guide notes in `camel-4x-upgrade-guide-4_24.adoc`, and in the 4.22.3 section of `camel-4x-upgrade-guide-4_22.adoc` for the backport, for users who replaced `apache5-client` / `netty-nio-client` with another HTTP client. They are in a separate commit, so the backport takes only the code. ### Tests `AwsClientBuilderUtilTest` registers, in its test resources, a class that is not an HTTP client as an `SdkHttpService` and an `SdkAsyncHttpService`. This reproduces the Kafka Connect failure in a plain unit test: - `sdkLookupFailsOnTheForeignRegistration`: a plain SDK builder fails with `ServiceConfigurationError ... not a subtype`, so the setup reproduces the bug. - `buildClientDoesNotUseTheSdkLookup` / `buildAsyncClientDoesNotUseTheSdkLookup`: clients built through `AwsClientBuilderUtil` are created. Without the fix, both fail with the reported error. - `sdkSettingLeavesTheChoiceToTheSdk`: with the SDK system property set, the SDK's own choice applies. The tests build STS clients, so `software.amazon.awssdk:sts` is added as a **test** dependency of `camel-aws-common`, which had no AWS service module on its test classpath. Validation: - `camel-aws-common`: all 7 tests pass. On `main` without the fix, the two client tests fail with the reported error. - `mvn verify -f components/camel-aws/pom.xml`: the unit tests of all 35 camel-aws modules pass (3476 tests, 0 failures, 0 errors, 180 skipped). ### Backport A draft backport to `camel-4.22.x` (AWS SDK 2.50.2, identical `AwsClientBuilderUtil`) follows and will be linked here. _Claude Code on behalf of Andrea Cosentino_ 🤖 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]
