« Return to Thread: NIO2: WatchService - Bug of feature?

NIO2: WatchService - Bug of feature?

by Thomas Meyer-2 :: Rate this Message:

| View in Thread

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

 « Return to Thread: NIO2: WatchService - Bug of feature?