Skip to content

Commit b27193c

Browse files
dagnirjoviegas
authored andcommitted
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.
1 parent 3248142 commit b27193c

7 files changed

Lines changed: 33 additions & 21 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"type": "feature",
3+
"category": "AWS SDK for Java v2",
4+
"contributor": "",
5+
"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."
6+
}

services/cloudfront/src/test/java/software/amazon/awssdk/services/cloudfront/CloudFrontUtilitiesIntegrationTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
import software.amazon.awssdk.http.SdkHttpClient;
5151
import software.amazon.awssdk.http.SdkHttpMethod;
5252
import software.amazon.awssdk.http.SdkHttpRequest;
53-
import software.amazon.awssdk.http.apache.ApacheHttpClient;
53+
import software.amazon.awssdk.http.apache5.Apache5HttpClient;
5454
import software.amazon.awssdk.services.cloudfront.cookie.CookiesForCannedPolicy;
5555
import software.amazon.awssdk.services.cloudfront.cookie.CookiesForCustomPolicy;
5656
import software.amazon.awssdk.services.cloudfront.internal.utils.SigningUtils;
@@ -142,7 +142,7 @@ static Stream<KeyTestCase> keyCases() throws Exception {
142142

143143
@Test
144144
void unsignedUrl_shouldReturn403Response() throws Exception {
145-
SdkHttpClient client = ApacheHttpClient.create();
145+
SdkHttpClient client = Apache5HttpClient.create();
146146
HttpExecuteResponse response =
147147
client.prepareRequest(HttpExecuteRequest.builder()
148148
.request(SdkHttpRequest.builder()
@@ -167,7 +167,7 @@ void getSignedUrlWithCannedPolicy_producesValidUrl(KeyTestCase testCase) throws
167167
.keyPairId(testCase.keyPairId)
168168
.expirationDate(expirationDate).build();
169169
SignedUrl signedUrl = cloudFrontUtilities.getSignedUrlWithCannedPolicy(request);
170-
SdkHttpClient client = ApacheHttpClient.create();
170+
SdkHttpClient client = Apache5HttpClient.create();
171171
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
172172
.request(signedUrl.createHttpGetRequest())
173173
.build()).call();
@@ -186,7 +186,7 @@ void getSignedUrlWithCannedPolicy_withExpiredDate_shouldReturn403Response(KeyTes
186186
.privateKey(testCase.privateKey)
187187
.keyPairId(testCase.keyPairId)
188188
.expirationDate(expirationDate));
189-
SdkHttpClient client = ApacheHttpClient.create();
189+
SdkHttpClient client = Apache5HttpClient.create();
190190
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
191191
.request(signedUrl.createHttpGetRequest())
192192
.build()).call();
@@ -207,7 +207,7 @@ void getSignedUrlWithCustomPolicy_producesValidUrl(KeyTestCase testCase) throws
207207
.expirationDate(expirationDate)
208208
.activeDate(activeDate).build();
209209
SignedUrl signedUrl = cloudFrontUtilities.getSignedUrlWithCustomPolicy(request);
210-
SdkHttpClient client = ApacheHttpClient.create();
210+
SdkHttpClient client = Apache5HttpClient.create();
211211
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
212212
.request(signedUrl.createHttpGetRequest())
213213
.build()).call();
@@ -227,7 +227,7 @@ void getSignedUrlWithCustomPolicy_withFutureActiveDate_shouldReturn403Response()
227227
.keyPairId(rsaKeyPairId)
228228
.expirationDate(expirationDate)
229229
.activeDate(activeDate));
230-
SdkHttpClient client = ApacheHttpClient.create();
230+
SdkHttpClient client = Apache5HttpClient.create();
231231
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
232232
.request(signedUrl.createHttpGetRequest())
233233
.build()).call();
@@ -245,7 +245,7 @@ void getCookiesForCannedPolicy_producesValidCookies(KeyTestCase testCase) throws
245245
.keyPairId(testCase.keyPairId)
246246
.expirationDate(expirationDate));
247247

248-
SdkHttpClient client = ApacheHttpClient.create();
248+
SdkHttpClient client = Apache5HttpClient.create();
249249
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
250250
.request(cookies.createHttpGetRequest())
251251
.build()).call();
@@ -266,7 +266,7 @@ void getCookiesForCannedPolicy_withExpiredDate_shouldReturn403Response() throws
266266
.expirationDate(expirationDate).build();
267267
CookiesForCannedPolicy cookies = cloudFrontUtilities.getCookiesForCannedPolicy(request);
268268

269-
SdkHttpClient client = ApacheHttpClient.create();
269+
SdkHttpClient client = Apache5HttpClient.create();
270270
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
271271
.request(cookies.createHttpGetRequest())
272272
.build()).call();
@@ -286,7 +286,7 @@ void getCookiesForCustomPolicy_producesValidCookies(KeyTestCase testCase) throws
286286
.expirationDate(expirationDate)
287287
.activeDate(activeDate));
288288

289-
SdkHttpClient client = ApacheHttpClient.create();
289+
SdkHttpClient client = Apache5HttpClient.create();
290290
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
291291
.request(cookies.createHttpGetRequest())
292292
.build()).call();
@@ -309,7 +309,7 @@ void getCookiesForCustomPolicy_withFutureActiveDate_shouldReturn403Response() th
309309
.activeDate(activeDate).build();
310310
CookiesForCustomPolicy cookies = cloudFrontUtilities.getCookiesForCustomPolicy(request);
311311

312-
SdkHttpClient client = ApacheHttpClient.create();
312+
SdkHttpClient client = Apache5HttpClient.create();
313313
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
314314
.request(cookies.createHttpGetRequest())
315315
.build()).call();
@@ -445,7 +445,7 @@ void getSignedUrlWithCustomPolicy_shouldAllowQueryParametersWhenUsingWildcard(Ke
445445
URI modifiedUri = URI.create(urlWithDynamicParam);
446446

447447

448-
SdkHttpClient client = ApacheHttpClient.create();
448+
SdkHttpClient client = Apache5HttpClient.create();
449449
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
450450
.request(SdkHttpRequest.builder()
451451
.encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery())
@@ -482,7 +482,7 @@ void getSignedUrlWithCustomPolicy_wildCardPath(KeyTestCase testCase) throws Exce
482482

483483

484484
URI modifiedUri = URI.create(signedUrl.url().replace("/specific-file","/other-file"));
485-
SdkHttpClient client = ApacheHttpClient.create();
485+
SdkHttpClient client = Apache5HttpClient.create();
486486
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
487487
.request(SdkHttpRequest.builder()
488488
.encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery())
@@ -518,7 +518,7 @@ void getSignedUrlWithCustomPolicy_wildCardPolicyResource_allowsAnyPath(KeyTestCa
518518

519519

520520
URI modifiedUri = URI.create(signedUrl.url().replace("/s3ObjectKey","/foo/other-file"));
521-
SdkHttpClient client = ApacheHttpClient.create();
521+
SdkHttpClient client = Apache5HttpClient.create();
522522
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
523523
.request(SdkHttpRequest.builder()
524524
.encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery())

services/dynamodb/src/it/java/software/amazon/awssdk/services/dynamodb/SignersIntegrationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
import software.amazon.awssdk.http.SdkHttpClient;
3838
import software.amazon.awssdk.http.SdkHttpFullRequest;
3939
import software.amazon.awssdk.http.SdkHttpMethod;
40-
import software.amazon.awssdk.http.apache.ApacheHttpClient;
40+
import software.amazon.awssdk.http.apache5.Apache5HttpClient;
4141
import software.amazon.awssdk.services.dynamodb.model.AttributeDefinition;
4242
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
4343
import software.amazon.awssdk.services.dynamodb.model.CreateTableRequest;
@@ -132,7 +132,7 @@ public void sign_WithoutUsingSdkClient_ThroughExecutionAttributes() throws Excep
132132
// sign the request
133133
SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructExecutionAttributes());
134134

135-
SdkHttpClient httpClient = ApacheHttpClient.builder().build();
135+
SdkHttpClient httpClient = Apache5HttpClient.builder().build();
136136

137137
HttpExecuteRequest request = HttpExecuteRequest.builder()
138138
.request(signedRequest)
@@ -156,7 +156,7 @@ public void test_SignMethod_WithModeledParam_And_WithoutUsingSdkClient() throws
156156
// sign the request
157157
SdkHttpFullRequest signedRequest = signer.sign(httpFullRequest, constructSignerParams());
158158

159-
SdkHttpClient httpClient = ApacheHttpClient.builder().build();
159+
SdkHttpClient httpClient = Apache5HttpClient.builder().build();
160160

161161
HttpExecuteRequest request = HttpExecuteRequest.builder()
162162
.request(signedRequest)

services/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@
531531
<version>${awsjavasdk.version}</version>
532532
</dependency>
533533
<dependency>
534-
<artifactId>apache-client</artifactId>
534+
<artifactId>apache5-client</artifactId>
535535
<groupId>software.amazon.awssdk</groupId>
536536
<version>${awsjavasdk.version}</version>
537537
<scope>runtime</scope>

services/s3/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@
203203
<version>${awsjavasdk.version}</version>
204204
<scope>test</scope>
205205
</dependency>
206+
<dependency>
207+
<groupId>software.amazon.awssdk</groupId>
208+
<artifactId>apache-client</artifactId>
209+
<version>${awsjavasdk.version}</version>
210+
<scope>test</scope>
211+
</dependency>
206212
<dependency>
207213
<groupId>io.netty</groupId>
208214
<artifactId>netty-transport</artifactId>

services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3AccessPointsIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import software.amazon.awssdk.http.HttpExecuteResponse;
3131
import software.amazon.awssdk.http.SdkHttpClient;
3232
import software.amazon.awssdk.http.SdkHttpRequest;
33-
import software.amazon.awssdk.http.apache.ApacheHttpClient;
33+
import software.amazon.awssdk.http.apache5.Apache5HttpClient;
3434
import software.amazon.awssdk.regions.Region;
3535
import software.amazon.awssdk.services.s3.S3Client;
3636
import software.amazon.awssdk.services.s3.model.GetObjectRequest;
@@ -147,7 +147,7 @@ private void testAccessPointPresigning(String accessPointArn, String key) throws
147147
.key(key)))
148148
.httpRequest();
149149

150-
try (SdkHttpClient client = ApacheHttpClient.create()) {
150+
try (SdkHttpClient client = Apache5HttpClient.create()) {
151151
client.prepareRequest(HttpExecuteRequest.builder()
152152
.request(presignedPut)
153153
.contentStreamProvider(() -> new StringInputStream(data))

services/s3control/src/it/java/software.amazon.awssdk.services.s3control/S3MrapIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
import software.amazon.awssdk.http.HttpExecuteRequest;
4545
import software.amazon.awssdk.http.HttpExecuteResponse;
4646
import software.amazon.awssdk.http.SdkHttpRequest;
47-
import software.amazon.awssdk.http.apache.ApacheHttpClient;
47+
import software.amazon.awssdk.http.apache5.Apache5HttpClient;
4848
import software.amazon.awssdk.http.auth.aws.signer.SignerConstant;
4949
import software.amazon.awssdk.regions.Region;
5050
import software.amazon.awssdk.services.s3.S3AsyncClient;
@@ -314,7 +314,7 @@ private String applyPresignedUrl(PresignedRequest presignedRequest, String conte
314314
builder.contentStreamProvider(() -> new StringInputStream(content));
315315
}
316316
HttpExecuteRequest request = builder.build();
317-
HttpExecuteResponse response = ApacheHttpClient.create().prepareRequest(request).call();
317+
HttpExecuteResponse response = Apache5HttpClient.create().prepareRequest(request).call();
318318
return response.responseBody()
319319
.map(stream -> invokeSafely(() -> IoUtils.toUtf8String(stream)))
320320
.orElseThrow(() -> new IOException("No input stream"));

0 commit comments

Comments
 (0)