# HG changeset patch # User alanb # Date 1399625227 -3600 # Node ID e73c2fb244de4cfde9fda948d597adf4708d1540 # Parent 39430f3393505722e0c41bd9dd50f2c2db9cbe03 8042816: (fs) Path.register doesn't throw IllegalArgumentException if multiple OVERFLOW events are specified, part 2 Reviewed-by: chegar diff -r 39430f339350 -r e73c2fb244de src/share/classes/sun/nio/fs/PollingWatchService.java --- a/src/share/classes/sun/nio/fs/PollingWatchService.java Wed May 07 16:50:40 2014 +0400 +++ b/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> eventSet = new HashSet>(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;