gmethvin / directory-watcher

A cross-platform Java recursive directory watcher, with a JNA macOS watcher and Scala better-files integration
Apache License 2.0
265 stars 34 forks source link

Use ExtendedWatchEventModifier.FILE_TREE when supported #2

Closed gmethvin closed 6 years ago

gmethvin commented 6 years ago

This modifier is supported on Windows, and allows us to watch the entire file tree recursively.

I've also set up AppVeyor to do builds on Windows: https://ci.appveyor.com/project/gmethvin/directory-watcher/branch/file-tree

akkie commented 6 years ago

@gmethvin :+1: No FileSystemException anymore.

I have one NullPointerException:

java.lang.NullPointerException: null
        at sun.nio.fs.WindowsPath.toWindowsPath(Unknown Source)
        at sun.nio.fs.WindowsPath.resolve(Unknown Source)
        at sun.nio.fs.WindowsPath.resolve(Unknown Source)
        at io.methvin.watcher.DirectoryWatcher.watch(DirectoryWatcher.java:131)
        at io.methvin.watcher.DirectoryWatcher.lambda$watchAsync$0(DirectoryWatcher.java:100)

All files were recognized and the other issues are fixed.

gmethvin commented 6 years ago

The NullPointerException looks similar to https://issues.apache.org/jira/browse/FELIX-5250. Any chance that file is on a mapped network drive?

gmethvin commented 6 years ago

Actually I updated to do a null check. It could be that it's an OVERFLOW event. If it's not, I throw an IllegalStateException there so you can at least figure out what's going on.

akkie commented 6 years ago

@gmethvin I had the exception only once and the file was not from a network drive. I'm not sure what was the cause.

gmethvin commented 6 years ago

Okay. Well, it seems like something that can happen on Windows under some circumstances, and since we're catching the exception it shouldn't be fatal. As long it's able to detect file changes I think we're ok.

akkie commented 6 years ago

:+1: Great