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".
This commit is contained in:
Simone Bordet 2016-08-14 23:25:03 +02:00
parent efc5265fe5
commit 11bc5cce66
1 changed files with 11 additions and 6 deletions

View File

@ -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