From 11bc5cce6663b03bb3c6f75832c3cfe65b6e0d5e Mon Sep 17 00:00:00 2001 From: Simone Bordet Date: Sun, 14 Aug 2016 23:25:03 +0200 Subject: [PATCH] Fixes #839 - Test Failure: MaxConcurrentStreamsTest.testOneConcurrentStream(). Fixed race condition where the prime request response was arriving to the client before the server had finished to clean up and remove the prime stream. Subsequent client requests were rejected because the prime stream was still "alive". --- .../client/http/MaxConcurrentStreamsTest.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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