Skip to content

Commit 658b97a

Browse files
authored
Throw UnsupportedOperationException if AwsCrtAsyncHttpClient is configured with HTTP/2 protocol (#3716)
1 parent db33dfe commit 658b97a

File tree

7 files changed

+47
-284
lines changed

7 files changed

+47
-284
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 CRT HTTP Client",
4+
"contributor": "",
5+
"description": "Throw UnsupportedOperationException if the AWS CRT HTTP Client is configured with HTTP/2 protocol."
6+
}

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

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,6 @@
152152
<version>${awsjavasdk.version}</version>
153153
<scope>test</scope>
154154
</dependency>
155-
<dependency>
156-
<groupId>software.amazon.awssdk</groupId>
157-
<artifactId>kms</artifactId>
158-
<version>${awsjavasdk.version}</version>
159-
<scope>test</scope>
160-
</dependency>
161155
<dependency>
162156
<groupId>software.amazon.awssdk</groupId>
163157
<artifactId>auth</artifactId>
@@ -180,33 +174,6 @@
180174

181175
<build>
182176
<plugins>
183-
<!-- The Reactive Streams TCK tests are based on TestNG. See http://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html#Running_TestNG_and_JUnit_Tests -->
184-
<plugin>
185-
<groupId>org.apache.maven.plugins</groupId>
186-
<artifactId>maven-surefire-plugin</artifactId>
187-
<version>${maven.surefire.version}</version>
188-
<configuration>
189-
<properties>
190-
<property>
191-
<name>junit</name>
192-
<value>false</value>
193-
</property>
194-
</properties>
195-
<threadCountClasses>1</threadCountClasses>
196-
</configuration>
197-
<dependencies>
198-
<dependency>
199-
<groupId>org.apache.maven.surefire</groupId>
200-
<artifactId>surefire-junit-platform</artifactId>
201-
<version>${maven.surefire.version}</version>
202-
</dependency>
203-
<dependency>
204-
<groupId>org.apache.maven.surefire</groupId>
205-
<artifactId>surefire-testng</artifactId>
206-
<version>${maven.surefire.version}</version>
207-
</dependency>
208-
</dependencies>
209-
</plugin>
210177
<plugin>
211178
<groupId>org.apache.maven.plugins</groupId>
212179
<artifactId>maven-jar-plugin</artifactId>

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

Lines changed: 0 additions & 142 deletions
This file was deleted.

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

Lines changed: 0 additions & 108 deletions
This file was deleted.

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package software.amazon.awssdk.http.crt;
1717

1818
import static software.amazon.awssdk.http.HttpMetric.HTTP_CLIENT_NAME;
19+
import static software.amazon.awssdk.http.SdkHttpConfigurationOption.PROTOCOL;
1920
import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely;
2021
import static software.amazon.awssdk.utils.Validate.paramNotNull;
2122

@@ -38,6 +39,7 @@
3839
import software.amazon.awssdk.crt.io.TlsCipherPreference;
3940
import software.amazon.awssdk.crt.io.TlsContext;
4041
import software.amazon.awssdk.crt.io.TlsContextOptions;
42+
import software.amazon.awssdk.http.Protocol;
4143
import software.amazon.awssdk.http.SdkHttpConfigurationOption;
4244
import software.amazon.awssdk.http.SdkHttpRequest;
4345
import software.amazon.awssdk.http.async.AsyncExecuteRequest;
@@ -89,6 +91,10 @@ public final class AwsCrtAsyncHttpClient implements SdkAsyncHttpClient {
8991
private boolean isClosed = false;
9092

9193
private AwsCrtAsyncHttpClient(DefaultBuilder builder, AttributeMap config) {
94+
if (config.get(PROTOCOL) == Protocol.HTTP2) {
95+
throw new UnsupportedOperationException("HTTP/2 is not supported in AwsCrtAsyncHttpClient yet. Use "
96+
+ "NettyNioAsyncHttpClient instead.");
97+
}
9298

9399
try (ClientBootstrap clientBootstrap = new ClientBootstrap(null, null);
94100
SocketOptions clientSocketOptions = buildSocketOptions(builder, config);

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
2424
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2525
import static software.amazon.awssdk.http.HttpTestUtils.createProvider;
26+
import static software.amazon.awssdk.http.SdkHttpConfigurationOption.PROTOCOL;
2627
import static software.amazon.awssdk.http.crt.CrtHttpClientTestUtils.createRequest;
2728

2829
import com.github.tomakehurst.wiremock.junit.WireMockRule;
@@ -33,10 +34,13 @@
3334
import org.junit.Rule;
3435
import org.junit.Test;
3536
import software.amazon.awssdk.crt.CrtResource;
37+
import software.amazon.awssdk.crt.Log;
38+
import software.amazon.awssdk.http.Protocol;
3639
import software.amazon.awssdk.http.RecordingResponseHandler;
3740
import software.amazon.awssdk.http.SdkHttpRequest;
3841
import software.amazon.awssdk.http.async.AsyncExecuteRequest;
3942
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
43+
import software.amazon.awssdk.utils.AttributeMap;
4044
import software.amazon.awssdk.utils.Logger;
4145

4246
public class AwsCrtHttpClientWireMockTest {
@@ -48,7 +52,8 @@ public class AwsCrtHttpClientWireMockTest {
4852

4953
@BeforeClass
5054
public static void setup() {
51-
System.setProperty("aws.crt.debugnative", "false");
55+
System.setProperty("aws.crt.debugnative", "true");
56+
Log.initLoggingToStdout(Log.LogLevel.Warn);
5257
}
5358

5459
@AfterClass
@@ -65,6 +70,15 @@ public void closeClient_reuse_throwException() throws Exception {
6570
assertThatThrownBy(() -> makeSimpleRequest(client)).hasMessageContaining("is closed");
6671
}
6772

73+
@Test
74+
public void invalidProtocol_shouldThrowException() {
75+
AttributeMap attributeMap = AttributeMap.builder()
76+
.put(PROTOCOL, Protocol.HTTP2)
77+
.build();
78+
assertThatThrownBy(() -> AwsCrtAsyncHttpClient.builder().buildWithDefaults(attributeMap))
79+
.isInstanceOf(UnsupportedOperationException.class);
80+
}
81+
6882
@Test
6983
public void sharedEventLoopGroup_closeOneClient_shouldNotAffectOtherClients() throws Exception {
7084
try (SdkAsyncHttpClient client = AwsCrtAsyncHttpClient.create()) {

0 commit comments

Comments
 (0)