davsclaus commented on code in PR #28563: URL: https://github.com/apache/camel/pull/28563#discussion_r4388902096
########## docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc: ########## @@ -307,6 +307,19 @@ closed that client for every other endpoint. Camel now closes only the clients it created. A client set with `amazonKinesisClient` or `amazonKinesisAsyncClient`, on the component or on an endpoint, is no longer closed when Camel stops: close it yourself when you no longer need it. +=== camel-aws - the HTTP client is no longer looked up on the classpath + +The camel-aws components now set the HTTP client of the AWS SDK clients they create: the Apache 5 client Review Comment: **Non-blocking: the note covers more clients than the change does.** "The camel-aws components now set the HTTP client of the AWS SDK clients they create" is true for clients built through `AwsClientBuilderUtil`, but some camel-aws code builds SDK clients directly and still uses the classpath lookup: - `SecretsManagerPropertiesFunction` (3 `SecretsManagerClient.builder()`) - `ParameterStorePropertiesFunction` (3 `SsmClient.builder()`) - `CloudTrailReloadTriggerTask` (`CloudTrailClient`, `SqsClient`) - `KclKinesis2Consumer` (`DynamoDbAsyncClient`, `CloudWatchAsyncClient`) - `Transcribe2ComponentVerifierExtension` The Secrets Manager vault and the KCL consumer can hit the same `ServiceConfigurationError ... not a subtype` on a Kafka Connect worker. Could they get the same default HTTP client (maybe via a small shared helper next to `useDefaultHttpClient`), or, if you prefer to keep this PR focused, could the note say it applies to the clients the components create for their endpoints? The same applies to the 4.22.3 note in `camel-4x-upgrade-guide-4_22.adoc`. ########## components/camel-aws/camel-aws-common/src/test/java/org/apache/camel/component/aws/common/AwsClientBuilderUtilTest.java: ########## @@ -0,0 +1,162 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.component.aws.common; + +import java.util.ServiceConfigurationError; + +import org.junit.jupiter.api.Test; +import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; +import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; +import software.amazon.awssdk.core.Protocol; +import software.amazon.awssdk.core.SdkSystemSetting; +import software.amazon.awssdk.core.exception.SdkClientException; +import software.amazon.awssdk.regions.Region; +import software.amazon.awssdk.services.sts.StsAsyncClient; +import software.amazon.awssdk.services.sts.StsClient; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** + * The test resources register {@link ForeignHttpService} as a sync and an async HTTP client implementation of the AWS + * SDK, which it is not. The SDK lookup of the HTTP client on the classpath then fails, as when a Kafka Connect plugin + * sees the registrations of the AWS SDK of the worker. + */ +class AwsClientBuilderUtilTest { + + private static final AwsCommonConfiguration CONFIGURATION = new StaticCredentialsConfiguration(); + + @Test + void sdkLookupFailsOnTheForeignRegistration() { + StaticCredentialsProvider credentials + = StaticCredentialsProvider.create(AwsBasicCredentials.create("accessKey", "secretKey")); + + assertThatThrownBy(() -> StsClient.builder().region(Region.US_EAST_1).credentialsProvider(credentials).build()) + .isInstanceOf(ServiceConfigurationError.class) + .hasMessageContaining("not a subtype"); + assertThatThrownBy(() -> StsAsyncClient.builder().region(Region.US_EAST_1).credentialsProvider(credentials).build()) + .isInstanceOf(ServiceConfigurationError.class) + .hasMessageContaining("not a subtype"); + } + + @Test + void buildClientDoesNotUseTheSdkLookup() { + try (StsClient client = AwsClientBuilderUtil.buildClient(CONFIGURATION, StsClient::builder)) { + assertThat(client).isNotNull(); + } + } + + @Test + void buildAsyncClientDoesNotUseTheSdkLookup() { + try (StsAsyncClient client = AwsClientBuilderUtil.buildAsyncClient(CONFIGURATION, StsAsyncClient::builder)) { + assertThat(client).isNotNull(); + } + } + + @Test + void sdkSettingLeavesTheChoiceToTheSdk() { Review Comment: **Suggestion:** only the sync setting (`SYNC_HTTP_SERVICE_IMPL`) is tested. A twin for `ASYNC_HTTP_SERVICE_IMPL` with `buildAsyncClient` / `StsAsyncClient` would cover the async branch of `useDefaultHttpClient` too. -- 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]
