[PATCH] Review quest for bug 8023878 TEST_BUG java/nio/file/WatchService/SensitivityModifier.java fails intermittently
Eric Wang
yiming.wang at oracle.com
Tue Sep 3 05:15:07 PDT 2013
Hi,
Please help to review the fix
http://cr.openjdk.java.net/~ewang/8023878/webrev.00/ for bug
https://bugs.openjdk.java.net/browse/JDK-8023878.
There's a defect in the loop of old test as below, if the eventRecived
is true, the while loop is broken which causes keys of watcher are not
reset, it causes the watcher.take() is hung in next execution in the for
loop.
for (int i=0; i<10; i++) {
......
boolean eventReceived = false;
WatchKey key = watcher.take();
do {
for (WatchEvent<?> event: key.pollEvents()) {
if (event.kind() != ENTRY_MODIFY)
throw new RuntimeException("Unexpected event: " + event);
Path name = ((WatchEvent<Path>)event).context();
if (name.equals(file.getFileName())) {
eventReceived = true;
break; // jump out to while loop and the events of the
key is not reset
}
}
key.reset();
key = watcher.poll(1, TimeUnit.SECONDS);
} while (key != null && !eventReceived)
Thanks,
Eric
More information about the nio-dev
mailing list