8003253: TEST_BUG: java/nio/channels/AsynchronousChannelGroup/Unbounded.java hang intermittently [win]
Alan Bateman
Alan.Bateman at oracle.com
Mon Nov 12 11:55:45 PST 2012
Daniel Fuchs pinged me to say that this started failing intermittently
him on Mac as soon as I pushed the change for 8003253.
Mea culpa, the patch does bring a problem. At the end of the test the
listener is closely and this the outstanding accept to fail with an
AsycnhronousCloseException and so sets "failed" to true. This creates a
race in that the main thread may see failed as true and fails the test.
I've created a new bug for this, 8003285, and the patch to fix this is
attached. If someone can review then we can sweep this one under the
carpet before anyone else notices.
-Alan
diff --git
a/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
b/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
--- a/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
+++ b/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
@@ -39,6 +39,9 @@
// set to true if an I/O operation fails
static volatile boolean failed;
+ // set to true when the test is done
+ static volatile boolean finished;
+
public static void main(String[] args) throws Exception {
// all accepted connections are added to a queue
final ArrayBlockingQueue<AsynchronousSocketChannel> queue =
@@ -54,8 +57,10 @@
listener.accept((Void)null, this);
}
public void failed(Throwable exc, Void att) {
- failed = true;
- System.err.println("accept failed: " + exc);
+ if (!finished) {
+ failed = true;
+ System.err.println("accept failed: " + exc);
+ }
}
});
System.out.println("Listener created.");
@@ -120,8 +125,11 @@
// wait for all threads to reach the barrier
System.out.println("Waiting for all threads to reach barrier");
barrier.await();
+
+ // finish up
+ finished = true;
listener.close();
if (failed)
- throw new RuntimeException("I/O failed failed, see log for
details");
+ throw new RuntimeException("I/O operation failed, see log
for details");
}
}
More information about the nio-dev
mailing list