Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top