Is it possible for any reason to register two WatchKeys per Path?

63 views Asked by At

I can't reproduce the issue in a minor example, but is it possible to register two different WatchKeys for one Path if the WatchService and the Kind<?>s are the same?

For instance if the parent-directory content changes?

1

There are 1 answers

0
Franz Ebner On BEST ANSWER

Yes it is, if you cancel the old one before registering the second one.

Due to the fact, that pending events, if any, remain pending and may be retrieved by invoking the pollEvents method after the key is cancelled, this seems to be reasonable.

The cancelled WatchKey stays invalid forever though.