Skip to content

Commit 25c0911

Browse files
committed
Upgrade Jetty (and some wiremock) version used for testing.
1 parent 5370feb commit 25c0911

File tree

14 files changed

+173
-75
lines changed

14 files changed

+173
-75
lines changed

bom-internal/pom.xml

Lines changed: 61 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,13 +296,6 @@
296296
<version>${wiremock.version}</version>
297297
<scope>test</scope>
298298
</dependency>
299-
<!-- Only use wiremock instead of wiremock-jre8 when working around bugs in the newer version -->
300-
<dependency>
301-
<groupId>com.github.tomakehurst</groupId>
302-
<artifactId>wiremock</artifactId>
303-
<version>2.18.0</version>
304-
<scope>compile</scope>
305-
</dependency>
306299
<dependency>
307300
<groupId>com.google.guava</groupId>
308301
<artifactId>guava</artifactId>
@@ -410,11 +403,71 @@
410403
<type>so</type>
411404
<scope>test</scope>
412405
</dependency>
406+
<dependency>
407+
<groupId>org.eclipse.jetty</groupId>
408+
<artifactId>jetty-server</artifactId>
409+
<version>${jetty.version}</version>
410+
</dependency>
411+
<dependency>
412+
<groupId>org.eclipse.jetty</groupId>
413+
<artifactId>jetty-servlet</artifactId>
414+
<version>${jetty.version}</version>
415+
</dependency>
416+
<dependency>
417+
<groupId>org.eclipse.jetty</groupId>
418+
<artifactId>jetty-servlets</artifactId>
419+
<version>${jetty.version}</version>
420+
</dependency>
421+
<dependency>
422+
<groupId>org.eclipse.jetty</groupId>
423+
<artifactId>jetty-webapp</artifactId>
424+
<version>${jetty.version}</version>
425+
</dependency>
426+
<dependency>
427+
<groupId>org.eclipse.jetty</groupId>
428+
<artifactId>jetty-proxy</artifactId>
429+
<version>${jetty.version}</version>
430+
</dependency>
431+
<dependency>
432+
<groupId>org.eclipse.jetty</groupId>
433+
<artifactId>jetty-alpn</artifactId>
434+
<version>${jetty.version}</version>
435+
</dependency>
436+
<dependency>
437+
<groupId>org.eclipse.jetty</groupId>
438+
<artifactId>jetty-alpn-server</artifactId>
439+
<version>${jetty.version}</version>
440+
</dependency>
441+
<dependency>
442+
<groupId>org.eclipse.jetty</groupId>
443+
<artifactId>jetty-alpn-java-server</artifactId>
444+
<version>${jetty.version}</version>
445+
</dependency>
446+
<dependency>
447+
<groupId>org.eclipse.jetty</groupId>
448+
<artifactId>jetty-alpn-openjdk8-server</artifactId>
449+
<version>${jetty.version}</version>
450+
</dependency>
451+
<dependency>
452+
<groupId>org.eclipse.jetty</groupId>
453+
<artifactId>jetty-alpn-java-client</artifactId>
454+
<version>${jetty.version}</version>
455+
</dependency>
456+
<dependency>
457+
<groupId>org.eclipse.jetty</groupId>
458+
<artifactId>jetty-alpn-openjdk8-client</artifactId>
459+
<version>${jetty.version}</version>
460+
</dependency>
461+
<dependency>
462+
<groupId>org.eclipse.jetty.http2</groupId>
463+
<artifactId>http2-server</artifactId>
464+
<version>${jetty.version}</version>
465+
</dependency>
413466
<dependency>
414467
<groupId>org.codehaus.plexus</groupId>
415468
<artifactId>plexus-utils</artifactId>
416469
<version>3.0.24</version>
417-
</dependency>
470+
</dependency>
418471
</dependencies>
419472
</dependencyManagement>
420473

http-clients/apache-client/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@
8383
<artifactId>hamcrest-all</artifactId>
8484
<scope>test</scope>
8585
</dependency>
86-
<!-- Use wiremock instead of wiremock-jre8 because HEAD request handling doesn't work in the newer versions. -->
8786
<dependency>
8887
<groupId>com.github.tomakehurst</groupId>
89-
<artifactId>wiremock</artifactId>
88+
<artifactId>wiremock-jre8</artifactId>
9089
<scope>test</scope>
9190
</dependency>
9291
</dependencies>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@
7373
</dependency>
7474

7575
<!--Test Dependencies-->
76-
<!-- Use wiremock instead of wiremock-jre8 because HEAD request handling doesn't work in the newer versions. -->
7776
<dependency>
7877
<groupId>com.github.tomakehurst</groupId>
79-
<artifactId>wiremock</artifactId>
78+
<artifactId>wiremock-jre8</artifactId>
8079
<scope>test</scope>
8180
</dependency>
8281
<dependency>

http-clients/netty-nio-client/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,9 @@
107107
<version>${awsjavasdk.version}</version>
108108
<scope>test</scope>
109109
</dependency>
110-
<!-- Use wiremock instead of wiremock-jre8 because HEAD request handling doesn't work in the newer versions. -->
111110
<dependency>
112111
<groupId>com.github.tomakehurst</groupId>
113-
<artifactId>wiremock</artifactId>
112+
<artifactId>wiremock-jre8</artifactId>
114113
<scope>test</scope>
115114
</dependency>
116115
<dependency>

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/NettyClientTlsAuthTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
1919
import static com.github.tomakehurst.wiremock.client.WireMock.get;
2020
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
21+
import static org.assertj.core.api.Assertions.assertThatThrownBy;
2122
import static org.hamcrest.core.IsInstanceOf.instanceOf;
2223
import static org.mockito.Mockito.mock;
2324
import static org.mockito.Mockito.verify;
@@ -26,6 +27,9 @@
2627
import com.github.tomakehurst.wiremock.WireMockServer;
2728
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
2829
import java.io.IOException;
30+
import java.util.concurrent.CompletionException;
31+
import javax.net.ssl.SSLException;
32+
import javax.net.ssl.SSLHandshakeException;
2933
import org.junit.After;
3034
import org.junit.AfterClass;
3135
import org.junit.BeforeClass;
@@ -172,13 +176,13 @@ public void proxyRequest_keyStoreSystemPropertiesConfigured_ableToAuthenticate()
172176

173177
@Test
174178
public void nonProxy_noKeyManagerGiven_shouldThrowException() {
175-
thrown.expectCause(instanceOf(IOException.class));
176-
thrown.expectMessage("The connection was closed");
177-
178179
netty = NettyNioAsyncHttpClient.builder()
179180
.buildWithDefaults(DEFAULTS);
180181

181-
HttpTestUtils.sendGetRequest(mockProxy.httpsPort(), netty).join();
182+
assertThatThrownBy(() -> HttpTestUtils.sendGetRequest(mockProxy.httpsPort(), netty).join())
183+
.isInstanceOf(CompletionException.class)
184+
.hasMessageContaining("SSL")
185+
.hasRootCauseInstanceOf(SSLException.class);
182186
}
183187

184188
private void sendRequest(SdkAsyncHttpClient client, SdkAsyncHttpResponseHandler responseHandler) {

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/RecordingResponseHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public void onError(Throwable error) {
7171

7272
}
7373

74-
String fullResponseAsString() {
74+
public String fullResponseAsString() {
7575
return bodyParts.toString();
7676
}
7777
}

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/internal/ConnectionReaperTest.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,51 +16,45 @@
1616
package software.amazon.awssdk.http.nio.netty.internal;
1717

1818
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
19+
import static com.github.tomakehurst.wiremock.client.WireMock.anyUrl;
1920
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
20-
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
2121
import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
2222
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
23+
import static org.assertj.core.api.Assertions.assertThat;
2324
import static org.mockito.ArgumentMatchers.any;
24-
import static org.mockito.Mockito.reset;
2525
import static org.mockito.Mockito.verify;
2626

2727
import com.github.tomakehurst.wiremock.client.WireMock;
28-
import com.github.tomakehurst.wiremock.http.trafficlistener.WiremockNetworkTrafficListener;
28+
import com.github.tomakehurst.wiremock.core.Options;
2929
import com.github.tomakehurst.wiremock.junit.WireMockRule;
3030
import java.net.URI;
3131
import java.time.Duration;
3232
import java.time.Instant;
33-
import org.junit.Before;
3433
import org.junit.Rule;
3534
import org.junit.Test;
3635
import org.junit.runner.RunWith;
37-
import org.mockito.Mockito;
3836
import org.mockito.internal.verification.AtLeast;
3937
import org.mockito.internal.verification.Times;
4038
import org.mockito.junit.MockitoJUnitRunner;
39+
import software.amazon.awssdk.http.ConnectionCountingTrafficListener;
40+
import software.amazon.awssdk.http.EmptyPublisher;
4141
import software.amazon.awssdk.http.SdkHttpConfigurationOption;
4242
import software.amazon.awssdk.http.SdkHttpMethod;
4343
import software.amazon.awssdk.http.SdkHttpRequest;
4444
import software.amazon.awssdk.http.async.AsyncExecuteRequest;
4545
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
46-
import software.amazon.awssdk.http.EmptyPublisher;
4746
import software.amazon.awssdk.http.nio.netty.NettyNioAsyncHttpClient;
4847
import software.amazon.awssdk.http.nio.netty.RecordingResponseHandler;
4948

5049
@RunWith(MockitoJUnitRunner.class)
5150
public class ConnectionReaperTest {
52-
private static final WiremockNetworkTrafficListener TRAFFIC_LISTENER = Mockito.mock(WiremockNetworkTrafficListener.class);
51+
private static final ConnectionCountingTrafficListener TRAFFIC_LISTENER = new ConnectionCountingTrafficListener();
5352

5453
@Rule
5554
public final WireMockRule mockServer = new WireMockRule(wireMockConfig().dynamicPort()
5655
.dynamicHttpsPort()
5756
.networkTrafficListener(TRAFFIC_LISTENER));
5857

59-
@Before
60-
public void methodSetup() {
61-
reset(TRAFFIC_LISTENER);
62-
}
63-
6458
@Test
6559
public void idleConnectionReaperDoesNotReapActiveConnections() throws InterruptedException {
6660
Duration maxIdleTime = Duration.ofSeconds(2);
@@ -71,16 +65,19 @@ public void idleConnectionReaperDoesNotReapActiveConnections() throws Interrupte
7165
Instant end = Instant.now().plus(maxIdleTime.plusSeconds(1));
7266

7367
// Send requests for longer than the max-idle time, ensuring no connections are closed.
68+
int connectionCount = TRAFFIC_LISTENER.openedConnections();
7469
while (Instant.now().isBefore(end)) {
7570
makeRequest(client);
7671
Thread.sleep(100);
77-
verify(TRAFFIC_LISTENER, new Times(0)).closed(any());
7872
}
7973

74+
assertThat(TRAFFIC_LISTENER.openedConnections()).isEqualTo(connectionCount + 1);
75+
8076
// Do nothing for longer than the max-idle time, ensuring connections are closed.
8177
Thread.sleep(maxIdleTime.plusSeconds(1).toMillis());
8278

83-
verify(TRAFFIC_LISTENER, new AtLeast(1)).closed(any());
79+
makeRequest(client);
80+
assertThat(TRAFFIC_LISTENER.openedConnections()).isEqualTo(connectionCount + 2);
8481
}
8582

8683
}
@@ -95,15 +92,15 @@ public void oldConnectionReaperReapsActiveConnections() throws InterruptedExcept
9592

9693
Instant end = Instant.now().plus(Duration.ofSeconds(5));
9794

98-
verify(TRAFFIC_LISTENER, new Times(0)).closed(any());
95+
int connectionCount = TRAFFIC_LISTENER.openedConnections();
9996

100-
// Send requests frequently, validating that connections are still being closed.
97+
// Send requests frequently, validating that new connections are being opened.
10198
while (Instant.now().isBefore(end)) {
10299
makeRequest(client);
103100
Thread.sleep(100);
104101
}
105102

106-
verify(TRAFFIC_LISTENER, new AtLeast(20)).closed(any());
103+
assertThat(TRAFFIC_LISTENER.openedConnections()).isGreaterThanOrEqualTo(connectionCount + 15);
107104
}
108105
}
109106

@@ -115,18 +112,19 @@ public void noReapingWorks() throws InterruptedException {
115112
.buildWithDefaults(SdkHttpConfigurationOption.GLOBAL_HTTP_DEFAULTS)) {
116113

117114

118-
verify(TRAFFIC_LISTENER, new Times(0)).closed(any());
115+
int connectionCount = TRAFFIC_LISTENER.openedConnections();
119116
makeRequest(client);
120-
121117
Thread.sleep(2_000);
122-
123-
verify(TRAFFIC_LISTENER, new Times(0)).closed(any());
118+
makeRequest(client);
119+
assertThat(TRAFFIC_LISTENER.openedConnections()).isEqualTo(connectionCount + 1);
124120
}
125121
}
126122

127123

128124
private void makeRequest(SdkAsyncHttpClient client) {
129-
stubFor(WireMock.any(urlPathEqualTo("/")).willReturn(aResponse().withBody(randomAlphabetic(10))));
125+
stubFor(WireMock.any(anyUrl()).willReturn(aResponse().withBody(randomAlphabetic(10))));
126+
127+
RecordingResponseHandler handler = new RecordingResponseHandler();
130128

131129
URI uri = URI.create("http://localhost:" + mockServer.port());
132130
client.execute(AsyncExecuteRequest.builder()
@@ -135,11 +133,14 @@ private void makeRequest(SdkAsyncHttpClient client) {
135133
.method(SdkHttpMethod.GET)
136134
.encodedPath("/")
137135
.putHeader("Host", uri.getHost())
136+
.putHeader("Content-Length", "0")
138137
.build())
139138
.requestContentPublisher(new EmptyPublisher())
140-
.responseHandler(new RecordingResponseHandler())
139+
.responseHandler(handler)
141140
.build())
142141
.join();
142+
143+
assertThat(handler.fullResponseAsString()).hasSize(10);
143144
}
144145

145146
}

http-clients/url-connection-client/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@
119119
<dependency>
120120
<groupId>org.eclipse.jetty</groupId>
121121
<artifactId>jetty-server</artifactId>
122-
<version>9.2.24.v20180105</version>
123122
<scope>test</scope>
124123
</dependency>
125124
</dependencies>

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
<dynamodb-local.version>1.16.0</dynamodb-local.version>
131131
<sqllite.version>1.0.392</sqllite.version>
132132
<blockhound.version>1.0.6.RELEASE</blockhound.version>
133+
<jetty.version>9.4.45.v20220203</jetty.version>
133134

134135
<!-- build plugin dependencies-->
135136
<maven.surefire.version>3.0.0-M5</maven.surefire.version>

test/http-client-tests/pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@
8383
<artifactId>mockito-core</artifactId>
8484
<scope>compile</scope>
8585
</dependency>
86-
<!-- Use wiremock instead of wiremock-jre8 because HEAD request handling doesn't work in the newer versions. -->
8786
<dependency>
8887
<groupId>com.github.tomakehurst</groupId>
89-
<artifactId>wiremock</artifactId>
88+
<artifactId>wiremock-jre8</artifactId>
9089
<scope>compile</scope>
9190
</dependency>
9291
<dependency>

0 commit comments

Comments
 (0)