Skip to content

Commit 6c6006e

Browse files
committed
8224024: java/util/concurrent/BlockingQueue/DrainToFails.java testBounded fails intermittently
Backport-of: 22a4313
1 parent c90bc80 commit 6c6006e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
/*
3636
* @test
3737
* @summary Test drainTo failing due to c.add throwing
38+
* @library /test/lib
3839
*/
3940

4041
import java.util.ArrayList;
@@ -50,9 +51,11 @@
5051
import java.util.concurrent.RunnableScheduledFuture;
5152
import java.util.concurrent.ScheduledThreadPoolExecutor;
5253
import java.util.concurrent.TimeUnit;
54+
import jdk.test.lib.Utils;
5355

5456
@SuppressWarnings({"unchecked", "rawtypes"})
5557
public class DrainToFails {
58+
static final long LONG_DELAY_MS = Utils.adjustTimeout(10_000);
5659
final int CAPACITY = 10;
5760
final int SMALL = 2;
5861

@@ -169,7 +172,7 @@ void testBounded(final BlockingQueue q) throws Throwable {
169172
fail("should throw");
170173
} catch (IllegalStateException success) {
171174
for (Thread putter : putters) {
172-
putter.join(2000L);
175+
putter.join(LONG_DELAY_MS);
173176
check(! putter.isAlive());
174177
}
175178
assertContentsInOrder(q2, 2, 3);
@@ -183,11 +186,10 @@ void testBounded(final BlockingQueue q) throws Throwable {
183186
}
184187
}
185188

186-
Runnable putter(final BlockingQueue q, final int elt) {
187-
return new Runnable() {
188-
public void run() {
189-
try { q.put(elt); }
190-
catch (Throwable t) { unexpected(t); }}};
189+
Runnable putter(BlockingQueue q, int elt) {
190+
return () -> {
191+
try { q.put(elt); }
192+
catch (Throwable t) { unexpected(t); }};
191193
}
192194

193195
void assertContentsInOrder(Iterable it, Object... contents) {

0 commit comments

Comments
 (0)