Skip to content

Commit 501ee26

Browse files
committed
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 3b11ae4 commit 501ee26

File tree

7 files changed

+33
-22
lines changed

7 files changed

+33
-22
lines changed
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 & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.nio.file.Files;
2626
import java.nio.file.Path;
2727
import java.nio.file.StandardOpenOption;
28-
import java.security.Key;
2928
import java.security.KeyPair;
3029
import java.security.KeyPairGenerator;
3130
import java.security.PrivateKey;
@@ -51,7 +50,7 @@
5150
import software.amazon.awssdk.http.SdkHttpClient;
5251
import software.amazon.awssdk.http.SdkHttpMethod;
5352
import software.amazon.awssdk.http.SdkHttpRequest;
54-
import software.amazon.awssdk.http.apache.ApacheHttpClient;
53+
import software.amazon.awssdk.http.apache5.Apache5HttpClient;
5554
import software.amazon.awssdk.services.cloudfront.cookie.CookiesForCannedPolicy;
5655
import software.amazon.awssdk.services.cloudfront.cookie.CookiesForCustomPolicy;
5756
import software.amazon.awssdk.services.cloudfront.internal.utils.SigningUtils;
@@ -144,7 +143,7 @@ static Stream<KeyTestCase> keyCases() throws Exception {
144143

145144
@Test
146145
void unsignedUrl_shouldReturn403Response() throws Exception {
147-
SdkHttpClient client = ApacheHttpClient.create();
146+
SdkHttpClient client = Apache5HttpClient.create();
148147
HttpExecuteResponse response =
149148
client.prepareRequest(HttpExecuteRequest.builder()
150149
.request(SdkHttpRequest.builder()
@@ -169,7 +168,7 @@ void getSignedUrlWithCannedPolicy_producesValidUrl(KeyTestCase testCase) throws
169168
.keyPairId(testCase.keyPairId)
170169
.expirationDate(expirationDate).build();
171170
SignedUrl signedUrl = cloudFrontUtilities.getSignedUrlWithCannedPolicy(request);
172-
SdkHttpClient client = ApacheHttpClient.create();
171+
SdkHttpClient client = Apache5HttpClient.create();
173172
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
174173
.request(signedUrl.createHttpGetRequest())
175174
.build()).call();
@@ -188,7 +187,7 @@ void getSignedUrlWithCannedPolicy_withExpiredDate_shouldReturn403Response(KeyTes
188187
.privateKey(testCase.privateKey)
189188
.keyPairId(testCase.keyPairId)
190189
.expirationDate(expirationDate));
191-
SdkHttpClient client = ApacheHttpClient.create();
190+
SdkHttpClient client = Apache5HttpClient.create();
192191
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
193192
.request(signedUrl.createHttpGetRequest())
194193
.build()).call();
@@ -209,7 +208,7 @@ void getSignedUrlWithCustomPolicy_producesValidUrl(KeyTestCase testCase) throws
209208
.expirationDate(expirationDate)
210209
.activeDate(activeDate).build();
211210
SignedUrl signedUrl = cloudFrontUtilities.getSignedUrlWithCustomPolicy(request);
212-
SdkHttpClient client = ApacheHttpClient.create();
211+
SdkHttpClient client = Apache5HttpClient.create();
213212
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
214213
.request(signedUrl.createHttpGetRequest())
215214
.build()).call();
@@ -229,7 +228,7 @@ void getSignedUrlWithCustomPolicy_withFutureActiveDate_shouldReturn403Response()
229228
.keyPairId(rsaKeyPairId)
230229
.expirationDate(expirationDate)
231230
.activeDate(activeDate));
232-
SdkHttpClient client = ApacheHttpClient.create();
231+
SdkHttpClient client = Apache5HttpClient.create();
233232
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
234233
.request(signedUrl.createHttpGetRequest())
235234
.build()).call();
@@ -247,7 +246,7 @@ void getCookiesForCannedPolicy_producesValidCookies(KeyTestCase testCase) throws
247246
.keyPairId(testCase.keyPairId)
248247
.expirationDate(expirationDate));
249248

250-
SdkHttpClient client = ApacheHttpClient.create();
249+
SdkHttpClient client = Apache5HttpClient.create();
251250
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
252251
.request(cookies.createHttpGetRequest())
253252
.build()).call();
@@ -268,7 +267,7 @@ void getCookiesForCannedPolicy_withExpiredDate_shouldReturn403Response() throws
268267
.expirationDate(expirationDate).build();
269268
CookiesForCannedPolicy cookies = cloudFrontUtilities.getCookiesForCannedPolicy(request);
270269

271-
SdkHttpClient client = ApacheHttpClient.create();
270+
SdkHttpClient client = Apache5HttpClient.create();
272271
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
273272
.request(cookies.createHttpGetRequest())
274273
.build()).call();
@@ -288,7 +287,7 @@ void getCookiesForCustomPolicy_producesValidCookies(KeyTestCase testCase) throws
288287
.expirationDate(expirationDate)
289288
.activeDate(activeDate));
290289

291-
SdkHttpClient client = ApacheHttpClient.create();
290+
SdkHttpClient client = Apache5HttpClient.create();
292291
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
293292
.request(cookies.createHttpGetRequest())
294293
.build()).call();
@@ -311,7 +310,7 @@ void getCookiesForCustomPolicy_withFutureActiveDate_shouldReturn403Response() th
311310
.activeDate(activeDate).build();
312311
CookiesForCustomPolicy cookies = cloudFrontUtilities.getCookiesForCustomPolicy(request);
313312

314-
SdkHttpClient client = ApacheHttpClient.create();
313+
SdkHttpClient client = Apache5HttpClient.create();
315314
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
316315
.request(cookies.createHttpGetRequest())
317316
.build()).call();
@@ -345,7 +344,7 @@ void getSignedUrlWithCustomPolicy_shouldAllowQueryParametersWhenUsingWildcard(Ke
345344
URI modifiedUri = URI.create(urlWithDynamicParam);
346345

347346

348-
SdkHttpClient client = ApacheHttpClient.create();
347+
SdkHttpClient client = Apache5HttpClient.create();
349348
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
350349
.request(SdkHttpRequest.builder()
351350
.encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery())
@@ -382,7 +381,7 @@ void getSignedUrlWithCustomPolicy_wildCardPath(KeyTestCase testCase) throws Exce
382381

383382

384383
URI modifiedUri = URI.create(signedUrl.url().replace("/specific-file","/other-file"));
385-
SdkHttpClient client = ApacheHttpClient.create();
384+
SdkHttpClient client = Apache5HttpClient.create();
386385
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
387386
.request(SdkHttpRequest.builder()
388387
.encodedPath(modifiedUri.getRawPath() + "?" + modifiedUri.getRawQuery())
@@ -418,7 +417,7 @@ void getSignedUrlWithCustomPolicy_wildCardPolicyResource_allowsAnyPath(KeyTestCa
418417

419418

420419
URI modifiedUri = URI.create(signedUrl.url().replace("/s3ObjectKey","/foo/other-file"));
421-
SdkHttpClient client = ApacheHttpClient.create();
420+
SdkHttpClient client = Apache5HttpClient.create();
422421
HttpExecuteResponse response = client.prepareRequest(HttpExecuteRequest.builder()
423422
.request(SdkHttpRequest.builder()
424423
.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
@@ -522,7 +522,7 @@
522522
<version>${awsjavasdk.version}</version>
523523
</dependency>
524524
<dependency>
525-
<artifactId>apache-client</artifactId>
525+
<artifactId>apache5-client</artifactId>
526526
<groupId>software.amazon.awssdk</groupId>
527527
<version>${awsjavasdk.version}</version>
528528
<scope>runtime</scope>

services/s3/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@
197197
<version>${awsjavasdk.version}</version>
198198
<scope>test</scope>
199199
</dependency>
200+
<dependency>
201+
<groupId>software.amazon.awssdk</groupId>
202+
<artifactId>apache-client</artifactId>
203+
<version>${awsjavasdk.version}</version>
204+
<scope>test</scope>
205+
</dependency>
200206
<dependency>
201207
<groupId>io.netty</groupId>
202208
<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;
@@ -144,7 +144,7 @@ private void testAccessPointPresigning(String accessPointArn, String key) throws
144144
.key(key)))
145145
.httpRequest();
146146

147-
try (SdkHttpClient client = ApacheHttpClient.create()) {
147+
try (SdkHttpClient client = Apache5HttpClient.create()) {
148148
client.prepareRequest(HttpExecuteRequest.builder()
149149
.request(presignedPut)
150150
.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)