Skip to content

Commit c447fe3

Browse files
authored
Minor refactoring to rename variables (#6763)
1 parent 1e84603 commit c447fe3

File tree

10 files changed

+46
-26
lines changed

10 files changed

+46
-26
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ public CompletableFuture<Void> execute(AsyncExecuteRequest asyncRequest) {
9292
* we have a pool and no one can destroy it underneath us until we've finished submitting the
9393
* request)
9494
*/
95-
HttpStreamManager crtConnPool = getOrCreateConnectionPool(poolKey(asyncRequest.request()));
95+
HttpStreamManager streamManager = getOrCreateConnectionPool(poolKey(asyncRequest.request()));
9696
CrtAsyncRequestContext context = CrtAsyncRequestContext.builder()
97-
.crtConnPool(crtConnPool)
97+
.streamManager(streamManager)
9898
.readBufferSize(this.readBufferSize)
9999
.request(asyncRequest)
100100
.protocol(this.protocol)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public ExecutableHttpRequest prepareRequest(HttpExecuteRequest request) {
9595
* we have a pool and no one can destroy it underneath us until we've finished submitting the
9696
* request)
9797
*/
98-
HttpStreamManager crtConnPool = getOrCreateConnectionPool(poolKey(request.httpRequest()));
98+
HttpStreamManager streamManager = getOrCreateConnectionPool(poolKey(request.httpRequest()));
9999
CrtRequestContext context = CrtRequestContext.builder()
100-
.crtConnPool(crtConnPool)
100+
.streamManager(streamManager)
101101
.readBufferSize(this.readBufferSize)
102102
.request(request)
103103
.build();

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
public final class CrtAsyncRequestContext {
2626
private final AsyncExecuteRequest request;
2727
private final long readBufferSize;
28-
private final HttpStreamManager crtConnPool;
28+
private final HttpStreamManager streamManager;
2929
private final MetricCollector metricCollector;
3030
private final Protocol protocol;
3131

3232
private CrtAsyncRequestContext(Builder builder) {
3333
this.request = builder.request;
3434
this.readBufferSize = builder.readBufferSize;
35-
this.crtConnPool = builder.crtConnPool;
35+
this.streamManager = builder.streamManager;
3636
this.metricCollector = request.metricCollector().orElse(null);
3737
this.protocol = builder.protocol;
3838
}
@@ -53,8 +53,8 @@ public Protocol protocol() {
5353
return protocol;
5454
}
5555

56-
public HttpStreamManager crtConnPool() {
57-
return crtConnPool;
56+
public HttpStreamManager streamManager() {
57+
return streamManager;
5858
}
5959

6060
public MetricCollector metricCollector() {
@@ -64,7 +64,7 @@ public MetricCollector metricCollector() {
6464
public static final class Builder {
6565
private AsyncExecuteRequest request;
6666
private long readBufferSize;
67-
private HttpStreamManager crtConnPool;
67+
private HttpStreamManager streamManager;
6868
private Protocol protocol;
6969

7070
private Builder() {
@@ -80,8 +80,8 @@ public Builder readBufferSize(long readBufferSize) {
8080
return this;
8181
}
8282

83-
public Builder crtConnPool(HttpStreamManager crtConnPool) {
84-
this.crtConnPool = crtConnPool;
83+
public Builder streamManager(HttpStreamManager streamManager) {
84+
this.streamManager = streamManager;
8585
return this;
8686
}
8787

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ private void doExecute(CrtAsyncRequestContext executionContext,
7171
CrtResponseAdapter.toCrtResponseHandler(requestFuture, asyncRequest.responseHandler());
7272

7373
CompletableFuture<HttpStreamBase> streamFuture =
74-
executionContext.crtConnPool().acquireStream(crtRequest, crtResponseHandler);
74+
executionContext.streamManager().acquireStream(crtRequest, crtResponseHandler);
7575

7676
long finalAcquireStartTime = acquireStartTime;
7777

7878
streamFuture.whenComplete((stream, throwable) -> {
7979
if (shouldPublishMetrics) {
80-
reportMetrics(executionContext.crtConnPool(), metricCollector, finalAcquireStartTime);
80+
reportMetrics(executionContext.streamManager(), metricCollector, finalAcquireStartTime);
8181
}
8282

8383
if (throwable != null) {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
public final class CrtRequestContext {
2525
private final HttpExecuteRequest request;
2626
private final long readBufferSize;
27-
private final HttpStreamManager crtConnPool;
27+
private final HttpStreamManager streamManager;
2828
private final MetricCollector metricCollector;
2929

3030
private CrtRequestContext(Builder builder) {
3131
this.request = builder.request;
3232
this.readBufferSize = builder.readBufferSize;
33-
this.crtConnPool = builder.crtConnPool;
33+
this.streamManager = builder.streamManager;
3434
this.metricCollector = request.metricCollector().orElse(null);
3535
}
3636

@@ -46,8 +46,8 @@ public long readBufferSize() {
4646
return readBufferSize;
4747
}
4848

49-
public HttpStreamManager crtConnPool() {
50-
return crtConnPool;
49+
public HttpStreamManager streamManager() {
50+
return streamManager;
5151
}
5252

5353
public MetricCollector metricCollector() {
@@ -57,7 +57,7 @@ public MetricCollector metricCollector() {
5757
public static final class Builder {
5858
private HttpExecuteRequest request;
5959
private long readBufferSize;
60-
private HttpStreamManager crtConnPool;
60+
private HttpStreamManager streamManager;
6161

6262
private Builder() {
6363
}
@@ -72,8 +72,8 @@ public Builder readBufferSize(long readBufferSize) {
7272
return this;
7373
}
7474

75-
public Builder crtConnPool(HttpStreamManager crtConnPool) {
76-
this.crtConnPool = crtConnPool;
75+
public Builder streamManager(HttpStreamManager streamManager) {
76+
this.streamManager = streamManager;
7777
return this;
7878
}
7979

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ private void doExecute(CrtRequestContext executionContext, CompletableFuture<Sdk
6262
HttpRequest crtRequest = CrtRequestAdapter.toCrtRequest(executionContext);
6363

6464
CompletableFuture<HttpStreamBase> streamFuture =
65-
executionContext.crtConnPool().acquireStream(crtRequest, crtResponseHandler);
65+
executionContext.streamManager().acquireStream(crtRequest, crtResponseHandler);
6666

6767
long finalAcquireStartTime = acquireStartTime;
6868

6969
streamFuture.whenComplete((streamBase, throwable) -> {
7070
if (shouldPublishMetrics) {
71-
reportMetrics(executionContext.crtConnPool(), metricCollector, finalAcquireStartTime);
71+
reportMetrics(executionContext.streamManager(), metricCollector, finalAcquireStartTime);
7272
}
7373

7474
if (throwable != null) {

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,19 @@
3838
@SdkInternalApi
3939
public final class CrtUtils {
4040
public static final int CRT_TLS_NEGOTIATION_ERROR_CODE = 1029;
41+
/**
42+
* Corresponds to CRT error: AWS_IO_SOCKET_TIMEOUT
43+
*/
4144
public static final int CRT_SOCKET_TIMEOUT = 1048;
4245

46+
4347
private CrtUtils() {
4448
}
4549

4650
public static Throwable wrapWithIoExceptionIfRetryable(HttpException httpException) {
4751
Throwable toThrow = httpException;
4852

53+
// TODO: switch to Crt.awsIsTransientError once https://github.com/awslabs/aws-crt-java/pull/972 is merged
4954
if (HttpClientConnection.isErrorRetryable(httpException)) {
5055
// IOExceptions get retried, and if the CRT says this error is retryable,
5156
// it's semantically an IOException anyway.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import io.netty.handler.ssl.SupportedCipherSuiteFilter;
5050
import io.netty.handler.ssl.util.SelfSignedCertificate;
5151
import java.io.IOException;
52+
import java.net.ServerSocket;
5253
import java.util.concurrent.CompletableFuture;
5354
import java.util.concurrent.CompletionException;
5455
import org.junit.jupiter.api.AfterEach;
@@ -95,6 +96,20 @@ public void serverSendsRstStream_shouldThrowIOException() throws Exception {
9596
}
9697
}
9798

99+
@Test
100+
public void tcpConnectFailure_shouldThrowIOException() throws Exception {
101+
int unusedPort;
102+
try (ServerSocket ss = new ServerSocket(0)) {
103+
unusedPort = ss.getLocalPort();
104+
}
105+
106+
CompletableFuture<?> request = sendGetRequest(unusedPort, client);
107+
assertThatThrownBy(request::join)
108+
.isInstanceOf(CompletionException.class)
109+
.hasCauseInstanceOf(IOException.class)
110+
.hasMessageContaining("An exception occurred");
111+
}
112+
98113
@Test
99114
public void serverSendsGoAway_shouldThrowIOException() throws Exception {
100115
H2ErrorServer server = new H2ErrorServer(ErrorType.GOAWAY);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void teardown() {
8383
@Test
8484
public void execute_requestConversionFails_invokesOnError() {
8585
CrtAsyncRequestContext context = CrtAsyncRequestContext.builder()
86-
.crtConnPool(streamManager)
86+
.streamManager(streamManager)
8787
.request(AsyncExecuteRequest.builder()
8888
.responseHandler(responseHandler)
8989
.build())
@@ -210,7 +210,7 @@ private CrtAsyncRequestContext crtAsyncRequestContext() {
210210
SdkHttpFullRequest request = createRequest(URI.create("http://localhost"));
211211
return CrtAsyncRequestContext.builder()
212212
.readBufferSize(2000)
213-
.crtConnPool(streamManager)
213+
.streamManager(streamManager)
214214
.request(AsyncExecuteRequest.builder()
215215
.request(request)
216216
.requestContentPublisher(createProvider(""))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public void teardown() {
8383
@Test
8484
public void execute_requestConversionFails_failsFuture() {
8585
CrtRequestContext context = CrtRequestContext.builder()
86-
.crtConnPool(streamManager)
86+
.streamManager(streamManager)
8787
.request(HttpExecuteRequest.builder().build())
8888
.build();
8989

@@ -154,7 +154,7 @@ private CrtRequestContext crtRequestContext() {
154154
SdkHttpFullRequest request = createRequest(URI.create("http://localhost"));
155155
return CrtRequestContext.builder()
156156
.readBufferSize(2000)
157-
.crtConnPool(streamManager)
157+
.streamManager(streamManager)
158158
.request(HttpExecuteRequest.builder()
159159
.request(request)
160160
.contentStreamProvider(SdkBytes.fromUtf8String("test").asContentStreamProvider())

0 commit comments

Comments
 (0)