Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-890d71f.json
Original file line number Diff line number Diff line change
@@ -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."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: version will be bumped before merging since releases done before then will cause merge conflicts.

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.security.Key;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.PrivateKey;
Expand All @@ -51,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;
Expand Down Expand Up @@ -144,7 +143,7 @@ static Stream<KeyTestCase> 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()
Expand All @@ -169,7 +168,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();
Expand All @@ -188,7 +187,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();
Expand All @@ -209,7 +208,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();
Expand All @@ -229,7 +228,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();
Expand All @@ -247,7 +246,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();
Expand All @@ -268,7 +267,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();
Expand All @@ -288,7 +287,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();
Expand All @@ -311,7 +310,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();
Expand Down Expand Up @@ -345,7 +344,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())
Expand Down Expand Up @@ -382,7 +381,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())
Expand Down Expand Up @@ -418,7 +417,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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<artifactId>apache-client</artifactId>
<artifactId>apache5-client</artifactId>
<groupId>software.amazon.awssdk</groupId>
<version>${awsjavasdk.version}</version>
<scope>runtime</scope>
Expand Down
6 changes: 6 additions & 0 deletions services/s3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@
<version>${awsjavasdk.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
<version>${awsjavasdk.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -144,7 +144,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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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"));
Expand Down
Loading