Skip to content

Commit

Permalink
8224024: java/util/concurrent/BlockingQueue/DrainToFails.java testBou…
Browse files Browse the repository at this point in the history
…nded fails intermittently

Backport-of: 22a4313
  • Loading branch information
GoeLin committed Feb 14, 2023
1 parent c90bc80 commit 6c6006e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/jdk/java/util/concurrent/BlockingQueue/DrainToFails.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
/*
* @test
* @summary Test drainTo failing due to c.add throwing
* @library /test/lib
*/

import java.util.ArrayList;
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

1 comment on commit 6c6006e

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.