Skip to content
Merged
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 `Apache5HttpClient` by default if no HTTP client is explicitly configured on the service client builder.\\n Notable changes:\\n - Apache 5 uses different logger names than Apache 4\\n - Expect: 100-Continue is disabled by default\\n - TCP keep-alive socket options require `jdk.net.NetworkPermission` when SecurityManager is active"
}
5 changes: 5 additions & 0 deletions aws-sdk-java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2188,6 +2188,11 @@ Amazon AutoScaling, etc).</description>
<artifactId>resiliencehubv2</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
<version>${awsjavasdk.version}</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}</finalName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -142,7 +142,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 @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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())
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
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
2 changes: 1 addition & 1 deletion services/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,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 @@ -203,6 +203,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 @@ -21,15 +21,14 @@

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;
import org.junit.Test;
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;
Expand All @@ -48,7 +47,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();
}
Expand All @@ -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
Expand Down
Loading
Loading