diff --git a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java index c64ed4f5a76..e597babdb1c 100644 --- a/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java +++ b/jetty-http2/http2-http-client-transport/src/test/java/org/eclipse/jetty/http2/client/http/MaxConcurrentStreamsTest.java @@ -64,8 +64,7 @@ public class MaxConcurrentStreamsTest extends AbstractTest } }); - // Prime the connection so that the maxConcurrentStream setting arrives to the client. - client.newRequest("localhost", connector.getLocalPort()).path("/prime").send(); + primeConnection(); CountDownLatch latch = new CountDownLatch(2); @@ -106,8 +105,7 @@ public class MaxConcurrentStreamsTest extends AbstractTest } }); - // Prime the connection so that the maxConcurrentStream setting arrives to the client. - client.newRequest("localhost", connector.getLocalPort()).path("/prime").send(); + primeConnection(); // Send requests up to the max allowed. for (int i = 0; i < maxStreams; ++i) @@ -150,8 +148,7 @@ public class MaxConcurrentStreamsTest extends AbstractTest } }); - // Prime the connection so that the maxConcurrentStream setting arrives to the client. - client.newRequest("localhost", connector.getLocalPort()).path("/prime").send(); + primeConnection(); // Send a request that is aborted while queued. client.newRequest("localhost", connector.getLocalPort()) @@ -165,6 +162,14 @@ public class MaxConcurrentStreamsTest extends AbstractTest Assert.assertEquals(HttpStatus.OK_200, response.getStatus()); } + private void primeConnection() throws Exception + { + // Prime the connection so that the maxConcurrentStream setting arrives to the client. + client.newRequest("localhost", connector.getLocalPort()).path("/prime").send(); + // Wait for the server to clean up and remove the stream that primes the connection. + sleep(1000); + } + private void sleep(long time) { try