Raise watch service sensitivity, add a delay in the test for windows to make sure the poll has been done

This commit is contained in:
Guillaume Nodet
2021-01-13 14:08:16 +01:00
parent 4bdedf12b0
commit 6dd4add35e
2 changed files with 14 additions and 1 deletions

View File

@@ -88,8 +88,17 @@ public class WatchServiceCacheFactory extends AbstractLogEnabled implements Cach
getLogger().debug("Starting to watch path " + key);
}
try {
WatchEvent.Modifier[] mods;
try {
mods = new WatchEvent.Modifier[] {
com.sun.nio.file.SensitivityWatchEventModifier.HIGH
};
} catch (Throwable t) {
mods = null;
}
final WatchKey watchKey = key.register(watchService,
StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY);
new WatchEvent.Kind[] { StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY },
mods);
return new Registration(watchKey);
} catch (IOException e) {
throw new RuntimeException(e);