6931216: TEST_BUG: test/java/nio/file/WatchService/LotsOfEvents.java failed with NPE
authoralanb
Wed, 03 Mar 2010 16:09:36 +0000
changeset 4985 574b8eb5c34e
parent 4984 48c6904d5e14
child 4986 25108bab43ad
6931216: TEST_BUG: test/java/nio/file/WatchService/LotsOfEvents.java failed with NPE Reviewed-by: chegar
jdk/test/java/nio/file/WatchService/LotsOfEvents.java
--- a/jdk/test/java/nio/file/WatchService/LotsOfEvents.java	Mon Mar 01 18:00:47 2010 +0000
+++ b/jdk/test/java/nio/file/WatchService/LotsOfEvents.java	Wed Mar 03 16:09:36 2010 +0000
@@ -102,7 +102,7 @@
 
         int nread = 0;
         boolean gotOverflow = false;
-        do {
+        while (key != null) {
             List<WatchEvent<?>> events = key.pollEvents();
             for (WatchEvent<?> event: events) {
                 WatchEvent.Kind<?> kind = event.kind();
@@ -122,7 +122,7 @@
             if (!key.reset())
                 throw new RuntimeException("Key is no longer valid");
             key = watcher.poll(2, TimeUnit.SECONDS);
-        } while (key != null);
+        }
 
         // check that all expected events were received or there was an overflow
         if (nread < count && !gotOverflow)
@@ -168,7 +168,7 @@
                 // process events and ensure that we don't get repeated modify
                 // events for the same file.
                 WatchKey key = watcher.poll(15, TimeUnit.SECONDS);
-                do {
+                while (key != null) {
                     Set<Path> modified = new HashSet<Path>();
                     for (WatchEvent<?> event: key.pollEvents()) {
                         WatchEvent.Kind<?> kind = event.kind();
@@ -186,7 +186,7 @@
                     if (!key.reset())
                         throw new RuntimeException("Key is no longer valid");
                     key = watcher.poll(2, TimeUnit.SECONDS);
-                } while (key != null);
+                }
             }
 
         } finally {