From b27193c885a87b4be496f791d7fdcbce2c3e2d2b Mon Sep 17 00:00:00 2001 From: Dongie Agnir Date: Wed, 11 Feb 2026 16:00:42 -0800 Subject: [PATCH 1/7] Swap apache-client with apache5-client This commit swaps the default apache-client dependency of service modules with apache5-client. Applications just relying on the default HTTP client will now use `Apache5HttpClient` as a result. --- .../feature-AWSSDKforJavav2-890d71f.json | 6 +++++ .../CloudFrontUtilitiesIntegrationTest.java | 26 +++++++++---------- .../dynamodb/SignersIntegrationTest.java | 6 ++--- services/pom.xml | 2 +- services/s3/pom.xml | 6 +++++ .../S3AccessPointsIntegrationTest.java | 4 +-- .../S3MrapIntegrationTest.java | 4 +-- 7 files changed, 33 insertions(+), 21 deletions(-) create mode 100644 .changes/next-release/feature-AWSSDKforJavav2-890d71f.json diff --git a/.changes/next-release/feature-AWSSDKforJavav2-890d71f.json b/.changes/next-release/feature-AWSSDKforJavav2-890d71f.json new file mode 100644 index 000000000000..86f2e341a48f --- /dev/null +++ b/.changes/next-release/feature-AWSSDKforJavav2-890d71f.json @@ -0,0 +1,6 @@ +{ + "type": "feature", + "category": "AWS SDK for Java v2", + "contributor": "", + "description": "This update replaces the default `apache-client` runtime dependency of service clients with the new `apache5-client`. This means that service clients will now use the `Apache5HttClient` by default if no HTTP client is explicitly configured on the service client builder. The SDK version is also updates to `2.42.0` to reflect this change in default client." +} diff --git a/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java b/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java index 0b14bcc83325..d4677e2af420 100644 --- a/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java +++ b/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java @@ -50,7 +50,7 @@ import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.http.SdkHttpRequest; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.services.cloudfront.cookie.CookiesForCannedPolicy; import software.amazon.awssdk.services.cloudfront.cookie.CookiesForCustomPolicy; import software.amazon.awssdk.services.cloudfront.internal.utils.SigningUtils; @@ -142,7 +142,7 @@ static Stream keyCases() throws Exception { @Test void unsignedUrl_shouldReturn403Response() throws Exception { - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(SdkHttpRequest.builder() @@ -167,7 +167,7 @@ void getSignedUrlWithCannedPolicy_producesValidUrl(KeyTestCase testCase) throws .keyPairId(testCase.keyPairId) .expirationDate(expirationDate).build(); SignedUrl signedUrl = cloudFrontUtilities.getSignedUrlWithCannedPolicy(request); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(signedUrl.createHttpGetRequest()) .build()).call(); @@ -186,7 +186,7 @@ void getSignedUrlWithCannedPolicy_withExpiredDate_shouldReturn403Response(KeyTes .privateKey(testCase.privateKey) .keyPairId(testCase.keyPairId) .expirationDate(expirationDate)); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(signedUrl.createHttpGetRequest()) .build()).call(); @@ -207,7 +207,7 @@ void getSignedUrlWithCustomPolicy_producesValidUrl(KeyTestCase testCase) throws .expirationDate(expirationDate) .activeDate(activeDate).build(); SignedUrl signedUrl = cloudFrontUtilities.getSignedUrlWithCustomPolicy(request); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(signedUrl.createHttpGetRequest()) .build()).call(); @@ -227,7 +227,7 @@ void getSignedUrlWithCustomPolicy_withFutureActiveDate_shouldReturn403Response() .keyPairId(rsaKeyPairId) .expirationDate(expirationDate) .activeDate(activeDate)); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(signedUrl.createHttpGetRequest()) .build()).call(); @@ -245,7 +245,7 @@ void getCookiesForCannedPolicy_producesValidCookies(KeyTestCase testCase) throws .keyPairId(testCase.keyPairId) .expirationDate(expirationDate)); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(cookies.createHttpGetRequest()) .build()).call(); @@ -266,7 +266,7 @@ void getCookiesForCannedPolicy_withExpiredDate_shouldReturn403Response() throws .expirationDate(expirationDate).build(); CookiesForCannedPolicy cookies = cloudFrontUtilities.getCookiesForCannedPolicy(request); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(cookies.createHttpGetRequest()) .build()).call(); @@ -286,7 +286,7 @@ void getCookiesForCustomPolicy_producesValidCookies(KeyTestCase testCase) throws .expirationDate(expirationDate) .activeDate(activeDate)); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(cookies.createHttpGetRequest()) .build()).call(); @@ -309,7 +309,7 @@ void getCookiesForCustomPolicy_withFutureActiveDate_shouldReturn403Response() th .activeDate(activeDate).build(); CookiesForCustomPolicy cookies = cloudFrontUtilities.getCookiesForCustomPolicy(request); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(cookies.createHttpGetRequest()) .build()).call(); @@ -445,7 +445,7 @@ void getSignedUrlWithCustomPolicy_shouldAllowQueryParametersWhenUsingWildcard(Ke URI modifiedUri = URI.create(urlWithDynamicParam); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(SdkHttpRequest.builder() .encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery()) @@ -482,7 +482,7 @@ void getSignedUrlWithCustomPolicy_wildCardPath(KeyTestCase testCase) throws Exce URI modifiedUri = URI.create(signedUrl.url().replace("/specific-file","/other-file")); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(SdkHttpRequest.builder() .encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery()) @@ -518,7 +518,7 @@ void getSignedUrlWithCustomPolicy_wildCardPolicyResource_allowsAnyPath(KeyTestCa URI modifiedUri = URI.create(signedUrl.url().replace("/s3ObjectKey","/foo/other-file")); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(SdkHttpRequest.builder() .encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery()) diff --git a/services/dynamodb/src/it/java/software/amazon/awssdk/services/dynamodb/SignersIntegrationTest.java b/services/dynamodb/src/it/java/software/amazon/awssdk/services/dynamodb/SignersIntegrationTest.java index e933e6b4f30c..758027150e37 100644 --- a/services/dynamodb/src/it/java/software/amazon/awssdk/services/dynamodb/SignersIntegrationTest.java +++ b/services/dynamodb/src/it/java/software/amazon/awssdk/services/dynamodb/SignersIntegrationTest.java @@ -37,7 +37,7 @@ import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition; import software.amazon.awssdk.services.dynamodb.model.AttributeValue; import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest; @@ -132,7 +132,7 @@ public void sign_WithoutUsingSdkClient_ThroughExecutionAttributes() throws Excep // sign the request SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructExecutionAttributes()); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); HttpExecuteRequest request = HttpExecuteRequest.builder() .request(signedRequest) @@ -156,7 +156,7 @@ public void test_SignMethod_WithModeledParam_And_WithoutUsingSdkClient() throws // sign the request SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructSignerParams()); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); HttpExecuteRequest request = HttpExecuteRequest.builder() .request(signedRequest) diff --git a/services/pom.xml b/services/pom.xml index 0643bb3d322d..6f6901611728 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -531,7 +531,7 @@ ${awsjavasdk.version} - apache-client + apache5-client software.amazon.awssdk ${awsjavasdk.version} runtime diff --git a/services/s3/pom.xml b/services/s3/pom.xml index a89a5538e058..dd149c9a155b 100644 --- a/services/s3/pom.xml +++ b/services/s3/pom.xml @@ -203,6 +203,12 @@ ${awsjavasdk.version} test + + software.amazon.awssdk + apache-client + ${awsjavasdk.version} + test + io.netty netty-transport diff --git a/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3AccessPointsIntegrationTest.java b/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3AccessPointsIntegrationTest.java index 95e4bf4e044b..e9dd6285800e 100644 --- a/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3AccessPointsIntegrationTest.java +++ b/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3AccessPointsIntegrationTest.java @@ -30,7 +30,7 @@ import software.amazon.awssdk.http.HttpExecuteResponse; import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.SdkHttpRequest; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.services.s3.model.GetObjectRequest; @@ -147,7 +147,7 @@ private void testAccessPointPresigning(String accessPointArn, String key) throws .key(key))) .httpRequest(); - try (SdkHttpClient client = ApacheHttpClient.create()) { + try (SdkHttpClient client = Apache5HttpClient.create()) { client.prepareRequest(HttpExecuteRequest.builder() .request(presignedPut) .contentStreamProvider(() -> new StringInputStream(data)) diff --git a/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3MrapIntegrationTest.java b/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3MrapIntegrationTest.java index 3fac572e29d9..1d38b036fdf4 100644 --- a/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3MrapIntegrationTest.java +++ b/services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3MrapIntegrationTest.java @@ -44,7 +44,7 @@ import software.amazon.awssdk.http.HttpExecuteRequest; import software.amazon.awssdk.http.HttpExecuteResponse; import software.amazon.awssdk.http.SdkHttpRequest; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.http.auth.aws.signer.SignerConstant; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3AsyncClient; @@ -314,7 +314,7 @@ private String applyPresignedUrl(PresignedRequest presignedRequest, String conte builder.contentStreamProvider(() -> new StringInputStream(content)); } HttpExecuteRequest request = builder.build(); - HttpExecuteResponse response = ApacheHttpClient.create().prepareRequest(request).call(); + HttpExecuteResponse response = Apache5HttpClient.create().prepareRequest(request).call(); return response.responseBody() .map(stream -> invokeSafely(() -> IoUtils.toUtf8String(stream))) .orElseThrow(() -> new IOException("No input stream")); From 5b95ceb53df82da357781a2d0c18e7012049999f Mon Sep 17 00:00:00 2001 From: Dongie Agnir Date: Wed, 22 Apr 2026 14:01:00 -0700 Subject: [PATCH 2/7] Fix CloudFrontUtilitiesIntegrationTest --- .../cloudfront/CloudFrontUtilitiesIntegrationTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java b/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java index d4677e2af420..fcfaee5b8dc4 100644 --- a/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java +++ b/services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java @@ -337,7 +337,7 @@ void getCookiesForCustomPolicy_shouldAllowQueryParametersWhenUsingWildcard(KeyTe // Request the same resource with an additional query parameter - should still be allowed by the wildcard policy URI uri = URI.create(resourceUrl + "?foo=bar"); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(SdkHttpRequest.builder() .uri(uri) @@ -372,7 +372,7 @@ void getCookiesForCustomPolicy_wildCardPath(KeyTestCase testCase) throws Excepti // Use the cookies to access a different file under the same wildcard path URI otherFileUri = URI.create(resourceUri + "/foo/other-file"); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(SdkHttpRequest.builder() .uri(otherFileUri) @@ -406,7 +406,7 @@ void getCookiesForCustomPolicy_wildCardPolicyResource_allowsAnyPath(KeyTestCase // Use the cookies to access a completely different path - the "*" pattern should allow any path URI differentPathUri = URI.create(resourceUrl.replace("/s3ObjectKey", "/foo/other-file")); - SdkHttpClient client = ApacheHttpClient.create(); + SdkHttpClient client = Apache5HttpClient.create(); HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder() .request(SdkHttpRequest.builder() .uri(differentPathUri) From 496694c5c1ebbc4c7f1991c4eaeb055db5f02ffb Mon Sep 17 00:00:00 2001 From: Dongie Agnir Date: Wed, 22 Apr 2026 14:19:01 -0700 Subject: [PATCH 3/7] Fix S3 tests --- services/s3/pom.xml | 2 +- ...ponseInputStreamTimeoutIntegrationTest.java | 4 ++-- .../s3/S3PresignerIntegrationTest.java | 14 +++++++------- .../S3CrossRegionCrtIntegrationTest.java | 8 +------- .../signer/AwsS3V4SignerIntegrationTest.java | 6 +++--- .../Expect100ContinueHeaderTest.java | 18 +++++++++--------- .../S3ExpressCreateSessionTest.java | 10 +++++----- .../s3/functionaltests/S3ExpressTest.java | 10 +++++----- .../S3ExpressCacheFunctionalTest.java | 6 +++--- 9 files changed, 36 insertions(+), 42 deletions(-) diff --git a/services/s3/pom.xml b/services/s3/pom.xml index dd149c9a155b..e1c72a9ee34c 100644 --- a/services/s3/pom.xml +++ b/services/s3/pom.xml @@ -205,7 +205,7 @@ software.amazon.awssdk - apache-client + apache5-client ${awsjavasdk.version} test diff --git a/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java b/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java index 2e07849567ab..922078a2a127 100644 --- a/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java +++ b/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java @@ -29,7 +29,7 @@ import software.amazon.awssdk.core.ResponseInputStream; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.services.s3.model.GetObjectRequest; import software.amazon.awssdk.services.s3.model.GetObjectResponse; import software.amazon.awssdk.services.s3.model.PutObjectRequest; @@ -48,7 +48,7 @@ public class ResponseInputStreamTimeoutIntegrationTest extends S3IntegrationTest @Before public void init() { s3Client = s3ClientBuilder() - .httpClientBuilder(ApacheHttpClient.builder().maxConnections(1)) + .httpClientBuilder(Apache5HttpClient.builder().maxConnections(1)) .overrideConfiguration(o -> o.retryStrategy(r -> r.maxAttempts(1))) .build(); } diff --git a/services/s3/src/it/java/software/amazon/awssdk/services/s3/S3PresignerIntegrationTest.java b/services/s3/src/it/java/software/amazon/awssdk/services/s3/S3PresignerIntegrationTest.java index 7e6ec50e3f8a..a618722b4ec8 100644 --- a/services/s3/src/it/java/software/amazon/awssdk/services/s3/S3PresignerIntegrationTest.java +++ b/services/s3/src/it/java/software/amazon/awssdk/services/s3/S3PresignerIntegrationTest.java @@ -37,7 +37,7 @@ import software.amazon.awssdk.http.HttpExecuteRequest; import software.amazon.awssdk.http.HttpExecuteResponse; import software.amazon.awssdk.http.SdkHttpClient; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.services.s3.model.AbortMultipartUploadRequest; import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest; import software.amazon.awssdk.services.s3.model.CreateMultipartUploadRequest; @@ -192,7 +192,7 @@ public void getObject_PresignedHttpRequestCanBeInvokedDirectlyBySdk() throws IOE assertThat(presigned.isBrowserExecutable()).isFalse(); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); // or UrlConnectionHttpClient.builder().build() + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); ContentStreamProvider requestPayload = presigned.signedPayload() .map(SdkBytes::asContentStreamProvider) @@ -226,7 +226,7 @@ public void deleteObject_PresignedHttpRequestCanBeInvokedDirectlyBySdk() throws assertThat(presigned.isBrowserExecutable()).isFalse(); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); // or UrlConnectionHttpClient.builder().build() + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); ContentStreamProvider requestPayload = presigned.signedPayload() .map(SdkBytes::asContentStreamProvider) @@ -255,7 +255,7 @@ public void putObject_PresignedHttpRequestCanBeInvokedDirectlyBySdk() throws IOE assertThat(presigned.isBrowserExecutable()).isFalse(); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); // or UrlConnectionHttpClient.builder().build() + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); ContentStreamProvider requestPayload = () -> new StringInputStream(testObjectContent); @@ -374,7 +374,7 @@ public void headObject_CanBePresigned() throws IOException { assertThat(presigned.isBrowserExecutable()).isFalse(); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); // or UrlConnectionHttpClient.builder().build() + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); HttpExecuteRequest request = HttpExecuteRequest.builder() .request(presigned.httpRequest()) @@ -397,7 +397,7 @@ public void headBucket_CanBePresigned() throws IOException { assertThat(presigned.isBrowserExecutable()).isFalse(); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); // or UrlConnectionHttpClient.builder().build() + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); HttpExecuteRequest request = HttpExecuteRequest.builder() .request(presigned.httpRequest()) @@ -442,7 +442,7 @@ private Optional getMultipartUpload(String objectKey) { } private HttpExecuteResponse execute(PresignedRequest presigned, String payload) throws IOException { - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); ContentStreamProvider requestPayload = payload == null ? null : () -> new StringInputStream(payload); diff --git a/services/s3/src/it/java/software/amazon/awssdk/services/s3/crossregion/S3CrossRegionCrtIntegrationTest.java b/services/s3/src/it/java/software/amazon/awssdk/services/s3/crossregion/S3CrossRegionCrtIntegrationTest.java index b90f147b54c0..89227d5e93a6 100644 --- a/services/s3/src/it/java/software/amazon/awssdk/services/s3/crossregion/S3CrossRegionCrtIntegrationTest.java +++ b/services/s3/src/it/java/software/amazon/awssdk/services/s3/crossregion/S3CrossRegionCrtIntegrationTest.java @@ -20,14 +20,8 @@ import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider; -import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3AsyncClient; -import software.amazon.awssdk.services.s3.S3Client; -import software.amazon.awssdk.services.s3.model.ListObjectsRequest; -import software.amazon.awssdk.services.s3.model.ListObjectsResponse; public class S3CrossRegionCrtIntegrationTest extends S3CrossRegionAsyncIntegrationTestBase { private static final String BUCKET = temporaryBucketName(S3CrossRegionCrtIntegrationTest.class); @@ -49,7 +43,7 @@ public void initialize() { .region(Region.AWS_GLOBAL) .credentialsProvider(CREDENTIALS_PROVIDER_CHAIN) .crossRegionAccessEnabled(true) - .build(); + .build(); } @Override protected String bucketName() { diff --git a/services/s3/src/it/java/software/amazon/awssdk/services/s3/signer/AwsS3V4SignerIntegrationTest.java b/services/s3/src/it/java/software/amazon/awssdk/services/s3/signer/AwsS3V4SignerIntegrationTest.java index 2cab5a15e4c8..4d7eb6556809 100644 --- a/services/s3/src/it/java/software/amazon/awssdk/services/s3/signer/AwsS3V4SignerIntegrationTest.java +++ b/services/s3/src/it/java/software/amazon/awssdk/services/s3/signer/AwsS3V4SignerIntegrationTest.java @@ -44,7 +44,7 @@ import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.services.s3.S3Client; import software.amazon.awssdk.services.s3.S3ClientBuilder; import software.amazon.awssdk.services.s3.S3IntegrationTestBase; @@ -117,7 +117,7 @@ public void test_SignMethod_WithModeledParam_And_WithoutUsingSdkClient() throws // sign the request SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructSignerParams()); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); HttpExecuteResponse response = httpClient.prepareRequest(HttpExecuteRequest.builder().request(signedRequest).build()) .call(); @@ -136,7 +136,7 @@ public void test_SignMethod_WithExecutionAttributes_And_WithoutUsingSdkClient() // sign the request SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructExecutionAttributes()); - SdkHttpClient httpClient = ApacheHttpClient.builder().build(); + SdkHttpClient httpClient = Apache5HttpClient.builder().build(); HttpExecuteResponse response = httpClient.prepareRequest(HttpExecuteRequest.builder().request(signedRequest).build()) .call(); diff --git a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java index e8f46caab9fb..3e51fb520e4a 100644 --- a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java +++ b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java @@ -50,7 +50,7 @@ import software.amazon.awssdk.http.ContentStreamProvider; import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.http.async.SdkAsyncHttpClient; import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient; import software.amazon.awssdk.http.crt.AwsCrtHttpClient; @@ -90,7 +90,7 @@ void setup(WireMockRuntimeInfo wmRuntimeInfo) { URI endpointOverride = URI.create(wmRuntimeInfo.getHttpsBaseUrl()); syncClient = S3Client.builder() - .httpClient(ApacheHttpClient.builder().buildWithDefaults(trustAllCerts())) + .httpClient(Apache5HttpClient.builder().buildWithDefaults(trustAllCerts())) .region(Region.US_EAST_1) .endpointOverride(endpointOverride) .requestChecksumCalculation(RequestChecksumCalculation.WHEN_REQUIRED) @@ -359,17 +359,17 @@ private S3Client buildSyncClient(String clientType, WireMockRuntimeInfo wmInfo, SdkHttpClient httpClient; switch (clientType) { case "APACHE": - httpClient = ApacheHttpClient.builder().buildWithDefaults(trustAllCerts()); + httpClient = Apache5HttpClient.builder().buildWithDefaults(trustAllCerts()); break; case "APACHE_EC_ENABLED": - httpClient = ApacheHttpClient.builder() - .expectContinueEnabled(true) - .buildWithDefaults(trustAllCerts()); + httpClient = Apache5HttpClient.builder() + .expectContinueEnabled(true) + .buildWithDefaults(trustAllCerts()); break; case "APACHE_EC_DISABLED": - httpClient = ApacheHttpClient.builder() - .expectContinueEnabled(false) - .buildWithDefaults(trustAllCerts()); + httpClient = Apache5HttpClient.builder() + .expectContinueEnabled(false) + .buildWithDefaults(trustAllCerts()); break; case "URL_CONNECTION": httpClient = UrlConnectionHttpClient.builder().buildWithDefaults(trustAllCerts()); diff --git a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressCreateSessionTest.java b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressCreateSessionTest.java index 815736f9d1e6..7185af94c4e5 100644 --- a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressCreateSessionTest.java +++ b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressCreateSessionTest.java @@ -53,7 +53,7 @@ import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.rules.testing.BaseRuleSetClientTest; import software.amazon.awssdk.http.SdkHttpRequest; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3AsyncClient; @@ -298,10 +298,10 @@ private void setEndpointParametersSync(S3ClientBuilder clientBuilder, Protocol p clientBuilder.endpointOverride(WM_HTTP_ENDPOINT.apply(wm)); } else { clientBuilder.endpointOverride(WM_HTTPS_ENDPOINT.apply(wm)) - .httpClient(ApacheHttpClient.builder() - .buildWithDefaults(AttributeMap.builder() - .put(TRUST_ALL_CERTIFICATES, TRUE) - .build())); + .httpClient(Apache5HttpClient.builder() + .buildWithDefaults(AttributeMap.builder() + .put(TRUST_ALL_CERTIFICATES, TRUE) + .build())); } } diff --git a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressTest.java b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressTest.java index 10414df6c14f..c10dd66ab024 100644 --- a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressTest.java +++ b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/S3ExpressTest.java @@ -54,7 +54,7 @@ import software.amazon.awssdk.core.rules.testing.BaseRuleSetClientTest; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.http.SdkHttpRequest; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.s3.S3AsyncClient; @@ -356,10 +356,10 @@ private S3Client getSyncClient(Protocol protocol, WireMockRuntimeInfo wm, S3Expr s3ClientBuilder.endpointOverride(WM_HTTP_ENDPOINT.apply(wm)); } else { s3ClientBuilder.endpointOverride(WM_HTTPS_ENDPOINT.apply(wm)) - .httpClient(ApacheHttpClient.builder() - .buildWithDefaults(AttributeMap.builder() - .put(TRUST_ALL_CERTIFICATES, TRUE) - .build())); + .httpClient(Apache5HttpClient.builder() + .buildWithDefaults(AttributeMap.builder() + .put(TRUST_ALL_CERTIFICATES, TRUE) + .build())); } if (s3ExpressSessionAuth == S3ExpressSessionAuth.DISABLE_AUTH) { s3ClientBuilder.disableS3ExpressSessionAuth(true); diff --git a/services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressCacheFunctionalTest.java b/services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressCacheFunctionalTest.java index 22b3e3983b71..abfe4fc744f3 100644 --- a/services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressCacheFunctionalTest.java +++ b/services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/s3express/S3ExpressCacheFunctionalTest.java @@ -52,7 +52,7 @@ import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.http.SdkHttpRequest; -import software.amazon.awssdk.http.apache.ApacheHttpClient; +import software.amazon.awssdk.http.apache5.Apache5HttpClient; import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; @@ -245,8 +245,8 @@ private S3ClientBuilder getS3ClientBuilder(WireMockRuntimeInfo wm) { .addExecutionInterceptor(PATH_STYLE_INTERCEPTOR)) .credentialsProvider(CLIENT_CREDENTIALS_PROVIDER) .endpointOverride(WM_HTTPS_ENDPOINT.apply(wm)) - .httpClient(ApacheHttpClient.builder() - .buildWithDefaults(AttributeMap.builder() + .httpClient(Apache5HttpClient.builder() + .buildWithDefaults(AttributeMap.builder() .put(TRUST_ALL_CERTIFICATES, TRUE) .build())); } From 5bfeb15837aa428ba26faf8999576d6d1ea570dd Mon Sep 17 00:00:00 2001 From: Dongie Agnir Date: Wed, 22 Apr 2026 14:20:43 -0700 Subject: [PATCH 4/7] Update version in changelog entry --- .changes/next-release/feature-AWSSDKforJavav2-890d71f.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changes/next-release/feature-AWSSDKforJavav2-890d71f.json b/.changes/next-release/feature-AWSSDKforJavav2-890d71f.json index 86f2e341a48f..225b3eb051ec 100644 --- a/.changes/next-release/feature-AWSSDKforJavav2-890d71f.json +++ b/.changes/next-release/feature-AWSSDKforJavav2-890d71f.json @@ -2,5 +2,5 @@ "type": "feature", "category": "AWS SDK for Java v2", "contributor": "", - "description": "This update replaces the default `apache-client` runtime dependency of service clients with the new `apache5-client`. This means that service clients will now use the `Apache5HttClient` by default if no HTTP client is explicitly configured on the service client builder. The SDK version is also updates to `2.42.0` to reflect this change in default client." + "description": "This update replaces the default `apache-client` runtime dependency of service clients with the new `apache5-client`. This means that service clients will now use the `Apache5HttClient` by default if no HTTP client is explicitly configured on the service client builder. The SDK version is also updates to `2.43.0` to reflect this change in default client." } From 344769f3bbc8dd0f141c5bfc3e348227218fa24b Mon Sep 17 00:00:00 2001 From: Dongie Agnir Date: Wed, 22 Apr 2026 15:19:20 -0700 Subject: [PATCH 5/7] Revert to 4.x for test Expect100ContinueHeaderTest tests 4.x specific behavior (default 100-continue). --- services/s3/pom.xml | 6 ++++++ .../Expect100ContinueHeaderTest.java | 18 +++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/services/s3/pom.xml b/services/s3/pom.xml index e1c72a9ee34c..24739bd9c2e8 100644 --- a/services/s3/pom.xml +++ b/services/s3/pom.xml @@ -203,6 +203,12 @@ ${awsjavasdk.version} test + + software.amazon.awssdk + apache-client + ${awsjavasdk.version} + test + software.amazon.awssdk apache5-client diff --git a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java index 3e51fb520e4a..e8f46caab9fb 100644 --- a/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java +++ b/services/s3/src/test/java/software/amazon/awssdk/services/s3/functionaltests/Expect100ContinueHeaderTest.java @@ -50,7 +50,7 @@ import software.amazon.awssdk.http.ContentStreamProvider; import software.amazon.awssdk.http.SdkHttpClient; import software.amazon.awssdk.http.SdkHttpConfigurationOption; -import software.amazon.awssdk.http.apache5.Apache5HttpClient; +import software.amazon.awssdk.http.apache.ApacheHttpClient; import software.amazon.awssdk.http.async.SdkAsyncHttpClient; import software.amazon.awssdk.http.crt.AwsCrtAsyncHttpClient; import software.amazon.awssdk.http.crt.AwsCrtHttpClient; @@ -90,7 +90,7 @@ void setup(WireMockRuntimeInfo wmRuntimeInfo) { URI endpointOverride = URI.create(wmRuntimeInfo.getHttpsBaseUrl()); syncClient = S3Client.builder() - .httpClient(Apache5HttpClient.builder().buildWithDefaults(trustAllCerts())) + .httpClient(ApacheHttpClient.builder().buildWithDefaults(trustAllCerts())) .region(Region.US_EAST_1) .endpointOverride(endpointOverride) .requestChecksumCalculation(RequestChecksumCalculation.WHEN_REQUIRED) @@ -359,17 +359,17 @@ private S3Client buildSyncClient(String clientType, WireMockRuntimeInfo wmInfo, SdkHttpClient httpClient; switch (clientType) { case "APACHE": - httpClient = Apache5HttpClient.builder().buildWithDefaults(trustAllCerts()); + httpClient = ApacheHttpClient.builder().buildWithDefaults(trustAllCerts()); break; case "APACHE_EC_ENABLED": - httpClient = Apache5HttpClient.builder() - .expectContinueEnabled(true) - .buildWithDefaults(trustAllCerts()); + httpClient = ApacheHttpClient.builder() + .expectContinueEnabled(true) + .buildWithDefaults(trustAllCerts()); break; case "APACHE_EC_DISABLED": - httpClient = Apache5HttpClient.builder() - .expectContinueEnabled(false) - .buildWithDefaults(trustAllCerts()); + httpClient = ApacheHttpClient.builder() + .expectContinueEnabled(false) + .buildWithDefaults(trustAllCerts()); break; case "URL_CONNECTION": httpClient = UrlConnectionHttpClient.builder().buildWithDefaults(trustAllCerts()); From 6cd3046c60fe16a47f0da85c6cf8b1be833d2c30 Mon Sep 17 00:00:00 2001 From: John Viegas <70235430+joviegas@users.noreply.github.com> Date: Fri, 15 May 2026 10:50:19 -0700 Subject: [PATCH 6/7] Add apache-client to aws-sdk-java module to prevent NoClassDefFoundError for customers using ApacheHttpClient in environments that bundle the whole SDK (e.g., EMR) after apache5-client default switch (#6964) --- aws-sdk-java/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aws-sdk-java/pom.xml b/aws-sdk-java/pom.xml index 25db4c0c1bb8..e5945808fcbe 100644 --- a/aws-sdk-java/pom.xml +++ b/aws-sdk-java/pom.xml @@ -2183,6 +2183,11 @@ Amazon AutoScaling, etc). interconnect ${awsjavasdk.version} + + software.amazon.awssdk + apache-client + ${awsjavasdk.version} + ${project.artifactId}-${project.version} From e4412be19b38a5fd608dcb7232ec26e7a86ef375 Mon Sep 17 00:00:00 2001 From: John Viegas <70235430+joviegas@users.noreply.github.com> Date: Mon, 18 May 2026 13:48:30 -0700 Subject: [PATCH 7/7] fix(integ-test): Fix Integ test issue after making Apache5 as default (#6974) * fix(dynamodb): Add TCP keep-alive permissions to SecurityManager test policy for Apache 5 compatibility. Apache 5.6 sets TCP_KEEPIDLE/INTERVAL/COUNT by default which requires jdk.net.NetworkPermission. * Fix ResponseInputStreamTimeoutIntegrationTest to update it to Apache5 exception assertion * Remove apache5-client test scope from s3/pom.xml to restore runtime transitivity. The test scope override prevented downstream modules like s3-transfer-manager from discovering the HTTP client via SPI * Dumy commit to trigger integ test * because we use org.apache.hc.core5.http.ConnectionRequestTimeoutException in ResponseInputStreamTimeoutIntegrationTest * Removing Apache5 specific execption from ResponseInputStreamTimeoutIntegrationTest and asserting just on error message * remove apache 5 as test dependency since it present as runtime --- .../services/dynamodb/security-manager-integ-test.policy | 5 +++++ services/s3/pom.xml | 6 ------ .../s3/ResponseInputStreamTimeoutIntegrationTest.java | 4 +--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/services/dynamodb/src/test/resources/software/amazon/awssdk/services/dynamodb/security-manager-integ-test.policy b/services/dynamodb/src/test/resources/software/amazon/awssdk/services/dynamodb/security-manager-integ-test.policy index 3737c5650c87..eadcb8739209 100644 --- a/services/dynamodb/src/test/resources/software/amazon/awssdk/services/dynamodb/security-manager-integ-test.policy +++ b/services/dynamodb/src/test/resources/software/amazon/awssdk/services/dynamodb/security-manager-integ-test.policy @@ -6,6 +6,11 @@ grant { permission "javax.net.ssl.SSLPermission" "setDefaultSSLContext"; permission "java.net.SocketPermission" "*", "connect,resolve"; + // Needed for Apache5 HTTP Client TCP keep-alive socket options + permission jdk.net.NetworkPermission "setOption.TCP_KEEPIDLE"; + permission jdk.net.NetworkPermission "setOption.TCP_KEEPINTERVAL"; + permission jdk.net.NetworkPermission "setOption.TCP_KEEPCOUNT"; + // Needed for test to remove the security manager permission java.lang.RuntimePermission "setSecurityManager"; diff --git a/services/s3/pom.xml b/services/s3/pom.xml index 24739bd9c2e8..dd149c9a155b 100644 --- a/services/s3/pom.xml +++ b/services/s3/pom.xml @@ -209,12 +209,6 @@ ${awsjavasdk.version} test - - software.amazon.awssdk - apache5-client - ${awsjavasdk.version} - test - io.netty netty-transport diff --git a/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java b/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java index 922078a2a127..d32b49af28e5 100644 --- a/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java +++ b/services/s3/src/it/java/software/amazon/awssdk/services/s3/ResponseInputStreamTimeoutIntegrationTest.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.time.Duration; -import org.apache.http.conn.ConnectionPoolTimeoutException; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; @@ -74,8 +73,7 @@ public void defaultTimeout_firstStreamNotConsumed_secondRequestTimesOut() { s3Client.getObject(getObjectRequest); assertThatThrownBy(() -> s3Client.getObject(getObjectRequest)) - .hasRootCauseInstanceOf(ConnectionPoolTimeoutException.class) - .hasMessageContaining("Timeout waiting for connection from pool"); + .hasMessageContaining("Timeout deadline"); } @Test