NIO2: WatchService - Bug of feature?

Thomas Meyer thomas at m3y3r.de
Sat May 5 01:12:12 PDT 2012


Hi,

sorry but this is a bit of topic, but as on this list a really many java
experts, I hope to get your opinion here:

I'm using a Path class to register a WatchService. The directory to
watch is: "/home/thomas/smServer/". The program itself is running with
working directory "/home/thomas/source/smServer".
When an WatchKey happens I get all WatchEvents and from the WatchEvents
the context(), i.e. a Path object again.
When doing a Path.toFile() on the context() of the WatchEvent it will be
"/home/thomas/source/smServer/file1" and not
"/home/thomas/smServer/file1" as I would expect because my watch
directory is "/home/thomas/smServer/"!

The Path returned by the watch event is relative, but the working
directory is used to construct the absolute path and not the path of the
directory that was registered to watch.

The javadoc isn't clear here on the new API in 1.7.

So what do you think: bug of feature?

with kind regards
thomas




More information about the distro-pkg-dev mailing list