Issue #4873 - add test to reproduce the ExecutorThreadPool.join() issue
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
parent
590b1a6ab1
commit
ae0b70fbfc
|
@ -18,7 +18,13 @@
|
||||||
|
|
||||||
package org.eclipse.jetty.util.thread;
|
package org.eclipse.jetty.util.thread;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool;
|
import org.eclipse.jetty.util.thread.ThreadPool.SizedThreadPool;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||||
|
|
||||||
public class ExecutorThreadPoolTest extends AbstractThreadPoolTest
|
public class ExecutorThreadPoolTest extends AbstractThreadPoolTest
|
||||||
{
|
{
|
||||||
|
@ -27,4 +33,22 @@ public class ExecutorThreadPoolTest extends AbstractThreadPoolTest
|
||||||
{
|
{
|
||||||
return new ExecutorThreadPool(max);
|
return new ExecutorThreadPool(max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testJoin() throws Exception
|
||||||
|
{
|
||||||
|
final long stopTimeout = 100;
|
||||||
|
ExecutorThreadPool executorThreadPool = new ExecutorThreadPool(10);
|
||||||
|
executorThreadPool.setStopTimeout(stopTimeout);
|
||||||
|
executorThreadPool.start();
|
||||||
|
|
||||||
|
// Verify that join does not timeout after waiting twice the stopTimeout.
|
||||||
|
assertThrows(Throwable.class, () ->
|
||||||
|
assertTimeoutPreemptively(Duration.ofMillis(stopTimeout * 2), executorThreadPool::join)
|
||||||
|
);
|
||||||
|
|
||||||
|
// After stopping the ThreadPool join should unblock.
|
||||||
|
executorThreadPool.stop();
|
||||||
|
assertTimeoutPreemptively(Duration.ofMillis(stopTimeout), executorThreadPool::join);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue