8003285: TEST_BUG: java/nio/channels/AsynchronousChannelGroup/Unbounded.java fails again [macosx]
authoralanb
Wed, 14 Nov 2012 12:56:26 +0000
changeset 14505 1a758bd5b548
parent 14504 aee973f6b53a
child 14506 9c33711ec566
8003285: TEST_BUG: java/nio/channels/AsynchronousChannelGroup/Unbounded.java fails again [macosx] Reviewed-by: chegar
jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java	Wed Nov 14 13:26:55 2012 +0800
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/Unbounded.java	Wed Nov 14 12:56:26 2012 +0000
@@ -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");
     }
 }