# HG changeset patch # User alanb # Date 1536940569 -3600 # Node ID 90c1dcdebc6447a3a99105d335cd960012f388f1 # Parent 1cb25b6589e9f4377a786b4a4fc8378909d73e7d 8208780: (se) test SelectWithConsumer.testReadableAndWriteable(): failure Reviewed-by: bpb diff -r 1cb25b6589e9 -r 90c1dcdebc64 test/jdk/java/nio/channels/Selector/SelectWithConsumer.java --- a/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java Fri Sep 14 14:44:11 2018 +0200 +++ b/test/jdk/java/nio/channels/Selector/SelectWithConsumer.java Fri Sep 14 16:56:09 2018 +0100 @@ -22,7 +22,7 @@ */ /* @test - * @bug 8199433 + * @bug 8199433 8208780 * @run testng SelectWithConsumer * @summary Unit test for Selector select(Consumer), select(Consumer,long) and * selectNow(Consumer) @@ -62,9 +62,19 @@ var interestOps = key.interestOps(); var notifiedOps = new AtomicInteger(); + if (expectedOps == 0) { + // ensure select(Consumer) does not block indefinitely + sel.wakeup(); + } else { + // ensure that the channel is ready for all expected operations + sel.select(); + while ((key.readyOps() & interestOps) != expectedOps) { + Thread.sleep(100); + sel.select(); + } + } + // select(Consumer) - if (expectedOps == 0) - sel.wakeup(); // ensure select does not block notifiedOps.set(0); int n = sel.select(k -> { assertTrue(Thread.currentThread() == callerThread);