diff --git a/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java b/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java index 0fc826a739e..45bb6811bfa 100644 --- a/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java +++ b/test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java @@ -35,6 +35,7 @@ /* * @test * @summary Test drainTo failing due to c.add throwing + * @library /test/lib */ import java.util.ArrayList; @@ -50,9 +51,11 @@ import java.util.concurrent.RunnableScheduledFuture; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import jdk.test.lib.Utils; @SuppressWarnings({"unchecked", "rawtypes"}) public class DrainToFails { + static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000); final int CAPACITY = 10; final int SMALL = 2; @@ -169,7 +172,7 @@ void testBounded(final BlockingQueue q) throws Throwable { fail("should throw"); } catch (IllegalStateException success) { for (Thread putter : putters) { - putter.join(2000L); + putter.join(LONG_DELAY_MS); check(! putter.isAlive()); } assertContentsInOrder(q2, 2, 3); @@ -183,11 +186,10 @@ void testBounded(final BlockingQueue q) throws Throwable { } } - Runnable putter(final BlockingQueue q, final int elt) { - return new Runnable() { - public void run() { - try { q.put(elt); } - catch (Throwable t) { unexpected(t); }}}; + Runnable putter(BlockingQueue q, int elt) { + return () -> { + try { q.put(elt); } + catch (Throwable t) { unexpected(t); }}; } void assertContentsInOrder(Iterable it, Object... contents) {