jdk/src/share/classes/sun/nio/fs/PollingWatchService.java
changeset 24362 c4ce2234c96e
parent 9679 d98ae8bc45fc
--- a/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java	Wed Jul 05 19:40:19 2017 +0200
+++ b/jdk/src/share/classes/sun/nio/fs/PollingWatchService.java	Fri May 09 09:47:07 2014 +0100
@@ -74,8 +74,6 @@
          throws IOException
     {
         // check events - CCE will be thrown if there are invalid elements
-        if (events.length == 0)
-            throw new IllegalArgumentException("No events to register");
         final Set<WatchEvent.Kind<?>> eventSet =
             new HashSet<WatchEvent.Kind<?>>(events.length);
         for (WatchEvent.Kind<?> event: events) {
@@ -90,8 +88,6 @@
 
             // OVERFLOW is ignored
             if (event == StandardWatchEventKinds.OVERFLOW) {
-                if (events.length == 1)
-                    throw new IllegalArgumentException("No events to register");
                 continue;
             }
 
@@ -100,6 +96,8 @@
                 throw new NullPointerException("An element in event set is 'null'");
             throw new UnsupportedOperationException(event.name());
         }
+        if (eventSet.isEmpty())
+            throw new IllegalArgumentException("No events to register");
 
         // A modifier may be used to specify the sensitivity level
         SensitivityWatchEventModifier sensivity = SensitivityWatchEventModifier.MEDIUM;