Closed kwin closed 2 years ago
I think it makes more sense to throw immediately if the watcher is closed. What do you think? Happy to accept a pull request to clarify docs.
IMHO just returning without throwing makes more sense. Otherwise I think watch can never return ordinarily. Exceptions should IMHO not be used for regular flow control and closing the watcher is IMHO the only means to end a dedicated watcher thread.
ok, I think I understand now. I agree that if watch()
is currently watching and the directory watcher is closed, we should return normally. But if you call watch()
on a watcher that is already closed, then it should throw, since calling watch
on a closed watcher doesn't make sense.
see #80
According to the javadoc of
DirectoryWatcher.watch()
(https://github.com/gmethvin/directory-watcher/blob/9eac61c0819db9ce67ac11e2b2c3927621c0fb8a/core/src/main/java/io/methvin/watcher/DirectoryWatcher.java#L224) itActually the methods throws a
java.nio.file.ClosedWatchServiceException
in case the watcher has been closed.Either this should be clarified in the javadoc or closing the watcher should just unblock
watch
without throwing an exception