Made `BlockedWritesWithSmallThreadPoolTest` more reliable.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
Simone Bordet 2021-08-25 12:39:06 +02:00
parent 9897c1b06e
commit 1b79fcee94
No known key found for this signature in database
GPG Key ID: 1677D141BCF3584D
1 changed files with 3 additions and 5 deletions

View File

@ -25,7 +25,6 @@ import java.util.concurrent.Callable;
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;
@ -251,10 +250,9 @@ public class BlockedWritesWithSmallThreadPoolTest
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(() -> {}));