PollingWatchService possible issue

Brian Burkhalter brian.burkhalter at oracle.com
Sat Dec 10 01:15:46 UTC 2016


This topic should be discussed on the nio-dev mailing list so I am re-directing the thread there. Please omit core-libs-dev from any replies, thanks.

On Dec 4, 2016, at 12:50 PM, Alan Snyder <fishgarage at cbfiddle.com> wrote:

> I notice that PollingWatchService never checks the file key when it reads a directory to see if it is reading from the same directory that it started with.

To clarify, do you intend that this check should be prior to the creation of the DirectoryStream at [1]?

> I suspect that creates a potential for incorrect behavior if the directory tree is rearranged (between polls) so that the original path accesses a different directory.
> Specifically, if the original directory remains available via some other path, then someone watching on that path or trying to register using that path will be using a watch service that is reading the wrong directory.

This does seem like a potential problem.



[1] http://hg.openjdk.java.net/jdk9/jdk9/jdk/file/3f4dab6bb48e/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java#l345
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20161209/5badb6ee/attachment.html>

More information about the nio-dev mailing list