Skip to content

Commit

Permalink
Made BlockedWritesWithSmallThreadPoolTest more reliable.
Browse files Browse the repository at this point in the history
Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
  • Loading branch information
sbordet committed Aug 25, 2021
1 parent 9897c1b commit 1b79fce
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -25,7 +25,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.IntStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

Expand Down Expand Up @@ -251,10 +250,9 @@ public void onHeaders(Stream stream, HeadersFrame frame)
Thread.sleep(1000);

CountDownLatch clientBlockLatch = new CountDownLatch(1);
// Make sure the application threads are blocked.
IntStream.range(0, clientThreads.getIdleThreads())
.forEach(i -> clientThreads.execute(() -> awaitUntil(0, () -> clientBlockLatch.await(15, TimeUnit.SECONDS))));
// Make sure the reserved threads are blocked.
// Make sure the application thread is blocked.
clientThreads.execute(() -> awaitUntil(0, () -> clientBlockLatch.await(15, TimeUnit.SECONDS)));
// Make sure the reserved thread is blocked.
if (clientThreads.getAvailableReservedThreads() != 1)
{
assertFalse(clientThreads.tryExecute(() -> {}));
Expand Down

0 comments on commit 1b79fce

Please sign in to comment.