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);

View File

@@ -44,6 +44,10 @@ public class DeleteRepoNativeIT {
client.execute(o1, "clean", "install", "-e", "-B").assertSuccess();
TestUtils.deleteDir(localMavenRepo, Os.current() != Os.WINDOWS);
if (Os.current() == Os.WINDOWS) {
// On windows, we're using the service watcher which polls every 2s by default
Thread.sleep(2500);
}
final TestClientOutput o2 = new TestClientOutput();
client.execute(o2, "clean", "install", "-e", "-B").assertSuccess();