You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FileSystem fs = Jimfs.newFileSystem(Configuration.unix());
Path data = fs.getPath("/data");
Files.createDirectory(data);
watcher = data.getFileSystem().newWatchService();
Thread watcherThread = new Thread(() -> {
WatchKey key;
try {
key = watcher.take(); // will be stuck here
while (key != null) {
for (WatchEvent<?> event : key.pollEvents()) {
System.out.printf("event of type: %s received for file: %s\n", event.kind(), event.context());
}
boolean isValid = key.reset();
}
} catch (Exception e) {
e.printStackTrace();
}
}, "CustomWatcher");
watcherThread.start();
data.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
Files.deleteIfExists(data);
When the registered directory gets deleted nothing happens at all but when using the default file system WatchService.take() actually stops waiting and the WatchKey for the registered directory gets invalidated.
The text was updated successfully, but these errors were encountered:
When the registered directory gets deleted nothing happens at all but when using the default file system
WatchService.take()
actually stops waiting and the WatchKey for the registered directory gets invalidated.The text was updated successfully, but these errors were encountered: