Skip to content

Commit b8a3be8

Browse files
committed
Update to 0.3.26 of the CRT with minor API changes
1 parent c159d0c commit b8a3be8

File tree

11 files changed

+36
-38
lines changed

11 files changed

+36
-38
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"category": "AWS SDK for Java v2",
3+
"type": "bugfix",
4+
"description": "Upgrade to the latest version (0.3.26) of the AWS Common Runtime."
5+
}

http-clients/aws-crt-client/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<dependency>
3434
<groupId>software.amazon.awssdk.crt</groupId>
3535
<artifactId>aws-crt</artifactId>
36-
<version>0.3.22</version>
36+
<version>0.3.26</version>
3737
</dependency>
3838

3939
<!--SDK dependencies-->

http-clients/aws-crt-client/src/it/java/software/amazon/awssdk/http/crt/AwsCrtClientCallingPatternIntegrationTest.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,8 @@ public void checkAllCombinations(@FromDataPoints("EventLoop") int eventLoopSize,
143143
@FromDataPoints("SharedClient") boolean useSharedClient) throws Exception {
144144

145145
try {
146-
if (CrtResource.getAllocatedNativeResourceCount() > 0) {
147-
System.err.println("Leaked Resources: " + String.join(", ", CrtResource.getAllocatedNativeResources()));
148-
}
149-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
150146

147+
CrtResource.waitForNoResources();
151148
String testName = String.format("Testing with eventLoopSize %d, connectionPoolSize %d, numberOfRequests %d, " +
152149
"numberOfParallelJavaClients %d, useSharedClient %b", eventLoopSize, connectionPoolSize,
153150
numberOfRequests, numberOfParallelClients, useSharedClient);
@@ -197,11 +194,7 @@ public void checkAllCombinations(@FromDataPoints("EventLoop") int eventLoopSize,
197194
awsCrtHttpClient.close();
198195
Assert.assertFalse(failed.get());
199196

200-
if (CrtResource.getAllocatedNativeResourceCount() > 0) {
201-
System.err.println("Leaked Resources: " + String.join(", ", CrtResource.getAllocatedNativeResources()));
202-
}
203-
204-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
197+
CrtResource.waitForNoResources();
205198

206199
float numSeconds = (float) ((System.currentTimeMillis() - start) / 1000.0);
207200
String timeElapsed = String.format("%.2f sec", numSeconds);

http-clients/aws-crt-client/src/it/java/software/amazon/awssdk/http/crt/AwsCrtClientKmsIntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class AwsCrtClientKmsIntegrationTest {
3535

3636
@Before
3737
public void setup() {
38-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
38+
CrtResource.waitForNoResources();
3939

4040
// Create an Http Client for each TLS Cipher Preference supported on the current platform
4141
for (TlsCipherPreference pref: TlsCipherPreference.values()) {
@@ -55,7 +55,7 @@ public void setup() {
5555

5656
@After
5757
public void tearDown() {
58-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
58+
CrtResource.waitForNoResources();
5959
}
6060

6161
private boolean doesKeyExist(KmsAsyncClient kms, String keyAlias) {

http-clients/aws-crt-client/src/it/java/software/amazon/awssdk/http/crt/AwsCrtClientS3IntegrationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class AwsCrtClientS3IntegrationTest {
5656

5757
@Before
5858
public void setup() {
59-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
59+
CrtResource.waitForNoResources();
6060

6161
crtClient = AwsCrtAsyncHttpClient.builder()
6262
.eventLoopSize(4)
@@ -74,7 +74,7 @@ public void tearDown() {
7474
s3.close();
7575
crtClient.close();
7676

77-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
77+
CrtResource.waitForNoResources();
7878
}
7979

8080
@Test

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/AwsCrtAsyncHttpClient.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import java.util.concurrent.atomic.AtomicBoolean;
3030
import software.amazon.awssdk.annotations.SdkPublicApi;
3131
import software.amazon.awssdk.crt.CrtResource;
32-
import software.amazon.awssdk.crt.http.HttpConnectionPoolManager;
32+
import software.amazon.awssdk.crt.http.HttpClientConnectionManager;
3333
import software.amazon.awssdk.crt.http.HttpHeader;
3434
import software.amazon.awssdk.crt.http.HttpRequest;
3535
import software.amazon.awssdk.crt.io.ClientBootstrap;
@@ -65,7 +65,7 @@ public class AwsCrtAsyncHttpClient implements SdkAsyncHttpClient {
6565
private static final String AWS_COMMON_RUNTIME = "AwsCommonRuntime";
6666
private static final int DEFAULT_STREAM_WINDOW_SIZE = 16 * 1024 * 1024; // 16 MB
6767

68-
private final Map<URI, HttpConnectionPoolManager> connectionPools = new ConcurrentHashMap<>();
68+
private final Map<URI, HttpClientConnectionManager> connectionPools = new ConcurrentHashMap<>();
6969
private final LinkedList<CrtResource> ownedSubResources = new LinkedList<>();
7070
private final AtomicBoolean isClosed = new AtomicBoolean(false);
7171
private final ClientBootstrap bootstrap;
@@ -95,7 +95,7 @@ public AwsCrtAsyncHttpClient(DefaultBuilder builder, AttributeMap config) {
9595

9696
bootstrap = own(new ClientBootstrap(builder.eventLoopSize));
9797
socketOptions = own(new SocketOptions());
98-
tlsContextOptions = own(new TlsContextOptions().withCipherPreference(builder.cipherPreference));
98+
tlsContextOptions = own(TlsContextOptions.createDefaultClient().withCipherPreference(builder.cipherPreference));
9999
tlsContextOptions.setVerifyPeer(builder.verifyPeer);
100100
tlsContext = own(new TlsContext(tlsContextOptions));
101101

@@ -131,22 +131,22 @@ public String clientName() {
131131
return AWS_COMMON_RUNTIME;
132132
}
133133

134-
private HttpConnectionPoolManager createConnectionPool(URI uri) {
134+
private HttpClientConnectionManager createConnectionPool(URI uri) {
135135
Validate.notNull(uri, "URI must not be null");
136136
log.debug(() -> "Creating ConnectionPool for: URI:" + uri + ", MaxConns: " + maxConnectionsPerEndpoint);
137137

138-
return new HttpConnectionPoolManager(bootstrap, socketOptions, tlsContext, uri,
139-
HttpConnectionPoolManager.DEFAULT_MAX_BUFFER_SIZE, windowSize,
138+
return new HttpClientConnectionManager(bootstrap, socketOptions, tlsContext, uri,
139+
HttpClientConnectionManager.DEFAULT_MAX_BUFFER_SIZE, windowSize,
140140
maxConnectionsPerEndpoint);
141141
}
142142

143-
private HttpConnectionPoolManager getOrCreateConnectionPool(URI uri) {
143+
private HttpClientConnectionManager getOrCreateConnectionPool(URI uri) {
144144
Validate.notNull(uri, "URI must not be null");
145-
HttpConnectionPoolManager connPool = connectionPools.get(uri);
145+
HttpClientConnectionManager connPool = connectionPools.get(uri);
146146

147147
if (connPool == null) {
148-
HttpConnectionPoolManager newConnPool = createConnectionPool(uri);
149-
HttpConnectionPoolManager alreadyExistingConnPool = connectionPools.putIfAbsent(uri, newConnPool);
148+
HttpClientConnectionManager newConnPool = createConnectionPool(uri);
149+
HttpClientConnectionManager alreadyExistingConnPool = connectionPools.putIfAbsent(uri, newConnPool);
150150

151151
if (alreadyExistingConnPool == null) {
152152
connPool = newConnPool;
@@ -222,7 +222,7 @@ public CompletableFuture<Void> execute(AsyncExecuteRequest asyncRequest) {
222222
Validate.notNull(asyncRequest.responseHandler(), "ResponseHandler must not be null");
223223

224224
URI uri = toUri(asyncRequest.request());
225-
HttpConnectionPoolManager crtConnPool = getOrCreateConnectionPool(uri);
225+
HttpClientConnectionManager crtConnPool = getOrCreateConnectionPool(uri);
226226
HttpRequest crtRequest = toCrtRequest(uri, asyncRequest);
227227

228228
CompletableFuture<Void> requestFuture = new CompletableFuture<>();
@@ -249,7 +249,7 @@ public CompletableFuture<Void> execute(AsyncExecuteRequest asyncRequest) {
249249
@Override
250250
public void close() {
251251
isClosed.set(true);
252-
for (HttpConnectionPoolManager connPool : connectionPools.values()) {
252+
for (HttpClientConnectionManager connPool : connectionPools.values()) {
253253
IoUtils.closeQuietly(connPool, log.logger());
254254
}
255255

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/internal/AwsCrtAsyncHttpStreamAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import software.amazon.awssdk.annotations.SdkInternalApi;
2323
import software.amazon.awssdk.crt.CRT;
2424
import software.amazon.awssdk.crt.http.CrtHttpStreamHandler;
25-
import software.amazon.awssdk.crt.http.HttpConnection;
25+
import software.amazon.awssdk.crt.http.HttpClientConnection;
2626
import software.amazon.awssdk.crt.http.HttpException;
2727
import software.amazon.awssdk.crt.http.HttpHeader;
2828
import software.amazon.awssdk.crt.http.HttpStream;
@@ -38,15 +38,15 @@
3838
public class AwsCrtAsyncHttpStreamAdapter implements CrtHttpStreamHandler {
3939
private static final Logger log = Logger.loggerFor(AwsCrtAsyncHttpStreamAdapter.class);
4040

41-
private final HttpConnection connection;
41+
private final HttpClientConnection connection;
4242
private final CompletableFuture<Void> responseComplete;
4343
private final AsyncExecuteRequest sdkRequest;
4444
private final SdkHttpResponse.Builder respBuilder = SdkHttpResponse.builder();
4545
private final int windowSize;
4646
private final AwsCrtRequestBodySubscriber requestBodySubscriber;
4747
private AwsCrtResponseBodyPublisher respBodyPublisher = null;
4848

49-
public AwsCrtAsyncHttpStreamAdapter(HttpConnection connection, CompletableFuture<Void> responseComplete,
49+
public AwsCrtAsyncHttpStreamAdapter(HttpClientConnection connection, CompletableFuture<Void> responseComplete,
5050
AsyncExecuteRequest sdkRequest, int windowSize) {
5151
Validate.notNull(connection, "HttpConnection is null");
5252
Validate.notNull(responseComplete, "reqComplete Future is null");
@@ -69,7 +69,7 @@ private void initRespBodyPublisherIfNeeded(HttpStream stream) {
6969
}
7070

7171
@Override
72-
public void onResponseHeaders(HttpStream stream, int responseStatusCode, HttpHeader[] nextHeaders) {
72+
public void onResponseHeaders(HttpStream stream, int responseStatusCode, int blockType, HttpHeader[] nextHeaders) {
7373
initRespBodyPublisherIfNeeded(stream);
7474

7575
respBuilder.statusCode(responseStatusCode);

http-clients/aws-crt-client/src/main/java/software/amazon/awssdk/http/crt/internal/AwsCrtResponseBodyPublisher.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.reactivestreams.Publisher;
2929
import org.reactivestreams.Subscriber;
3030
import software.amazon.awssdk.annotations.SdkInternalApi;
31-
import software.amazon.awssdk.crt.http.HttpConnection;
31+
import software.amazon.awssdk.crt.http.HttpClientConnection;
3232
import software.amazon.awssdk.crt.http.HttpStream;
3333
import software.amazon.awssdk.utils.Logger;
3434
import software.amazon.awssdk.utils.Validate;
@@ -41,7 +41,7 @@ public class AwsCrtResponseBodyPublisher implements Publisher<ByteBuffer> {
4141
private static final Logger log = Logger.loggerFor(AwsCrtResponseBodyPublisher.class);
4242
private static final LongUnaryOperator DECREMENT_IF_GREATER_THAN_ZERO = x -> ((x > 0) ? (x - 1) : (x));
4343

44-
private final HttpConnection connection;
44+
private final HttpClientConnection connection;
4545
private final HttpStream stream;
4646
private final CompletableFuture<Void> responseComplete;
4747
private final AtomicLong outstandingRequests = new AtomicLong(0);
@@ -62,7 +62,7 @@ public class AwsCrtResponseBodyPublisher implements Publisher<ByteBuffer> {
6262
* @param windowSize The max allowed bytes to be queued. The sum of the sizes of all queued ByteBuffers should
6363
* never exceed this value.
6464
*/
65-
public AwsCrtResponseBodyPublisher(HttpConnection connection, HttpStream stream,
65+
public AwsCrtResponseBodyPublisher(HttpClientConnection connection, HttpStream stream,
6666
CompletableFuture<Void> responseComplete, int windowSize) {
6767
Validate.notNull(connection, "HttpConnection must not be null");
6868
Validate.notNull(stream, "Stream must not be null");

http-clients/aws-crt-client/src/test/java/software/amazon/awssdk/http/crt/AwsCrtHttpClientSpiVerificationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class AwsCrtHttpClientSpiVerificationTest {
6868

6969
@Before
7070
public void setup() throws Exception {
71-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
71+
CrtResource.waitForNoResources();
7272

7373
client = AwsCrtAsyncHttpClient.builder()
7474
.build();
@@ -77,7 +77,7 @@ public void setup() throws Exception {
7777
@After
7878
public void tearDown() {
7979
client.close();
80-
Assert.assertEquals("Expected Zero allocated AwsCrtResources", 0, CrtResource.getAllocatedNativeResourceCount());
80+
CrtResource.waitForNoResources();
8181
}
8282

8383
private byte[] generateRandomBody(int size) {

http-clients/aws-crt-client/src/test/java/software/amazon/awssdk/http/crt/AwsCrtResponseBodyPublisherReactiveStreamCompatTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.reactivestreams.Publisher;
2424
import org.reactivestreams.tck.PublisherVerification;
2525
import org.reactivestreams.tck.TestEnvironment;
26-
import software.amazon.awssdk.crt.http.HttpConnection;
26+
import software.amazon.awssdk.crt.http.HttpClientConnection;
2727
import software.amazon.awssdk.crt.http.HttpStream;
2828
import software.amazon.awssdk.http.crt.internal.AwsCrtResponseBodyPublisher;
2929
import software.amazon.awssdk.utils.Logger;
@@ -37,7 +37,7 @@ public AwsCrtResponseBodyPublisherReactiveStreamCompatTest() {
3737

3838
@Override
3939
public Publisher<ByteBuffer> createPublisher(long elements) {
40-
HttpConnection connection = mock(HttpConnection.class);
40+
HttpClientConnection connection = mock(HttpClientConnection.class);
4141
HttpStream stream = mock(HttpStream.class);
4242
AwsCrtResponseBodyPublisher bodyPublisher = new AwsCrtResponseBodyPublisher(connection, stream, new CompletableFuture<>(), Integer.MAX_VALUE);
4343

test/sdk-benchmarks/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
<dependency>
194194
<groupId>software.amazon.awssdk.crt</groupId>
195195
<artifactId>aws-crt</artifactId>
196-
<version>0.3.22</version>
196+
<version>0.3.26</version>
197197
<scope>compile</scope>
198198
</dependency>
199199
<dependency>

0 commit comments

Comments
 (0)