8163136: Add print statements to java/nio/file/WatchService/LotsOfCancels.java
Summary: Add some print statements.
Reviewed-by: alanb
--- a/jdk/test/java/nio/file/WatchService/LotsOfCancels.java Wed Aug 24 10:58:29 2016 -0700
+++ b/jdk/test/java/nio/file/WatchService/LotsOfCancels.java Wed Aug 24 11:23:58 2016 -0700
@@ -53,10 +53,11 @@
Path testDir = Paths.get(System.getProperty("test.dir", "."));
Path top = Files.createTempDirectory(testDir, "LotsOfCancels");
for (int i=1; i<=16; i++) {
+ int id = i;
Path dir = Files.createDirectory(top.resolve("dir-" + i));
WatchService watcher = FileSystems.getDefault().newWatchService();
- pool.submit(() -> handle(dir, watcher));
- pool.submit(() -> poll(watcher));
+ pool.submit(() -> handle(id, dir, watcher));
+ pool.submit(() -> poll(id, watcher));
}
} finally {
pool.shutdown();
@@ -74,7 +75,8 @@
* Stress the given WatchService, specifically the cancel method, in
* the given directory. Closes the WatchService when done.
*/
- static void handle(Path dir, WatchService watcher) {
+ static void handle(int id, Path dir, WatchService watcher) {
+ System.out.printf("begin handle %d%n", id);
try {
try {
Path file = dir.resolve("anyfile");
@@ -85,12 +87,15 @@
key.cancel();
}
} finally {
+ System.out.printf("WatchService %d closing ...%n", id);
watcher.close();
+ System.out.printf("WatchService %d closed %n", id);
}
} catch (Exception e) {
e.printStackTrace();
failed = true;
}
+ System.out.printf("end handle %d%n", id);
}
/**
@@ -98,7 +103,8 @@
* queue drained, it also hogs a CPU core which seems necessary to
* tickle the original bug.
*/
- static void poll(WatchService watcher) {
+ static void poll(int id, WatchService watcher) {
+ System.out.printf("begin poll %d%n", id);
try {
for (;;) {
WatchKey key = watcher.take();
@@ -108,10 +114,12 @@
}
}
} catch (ClosedWatchServiceException expected) {
- // nothing to do
+ // nothing to do but print
+ System.out.printf("poll %d expected exception %s%n", id, expected);
} catch (Exception e) {
e.printStackTrace();
failed = true;
}
+ System.out.printf("end poll %d%n", id);
}
}