WatchService 应该在注册时阻塞吗?
Should WatchService be blocking on register?
我的软件用户在为文件夹添加监视时遇到问题。对 register
的调用似乎永远阻塞。这是来自用户机器的线程转储:
platformExecutor [01-12_10:14]" Id=56 WAITING on sun.nio.fs.AbstractPoller$Request@1492d01
at java.lang.Object.wait(Native Method)
- waiting on sun.nio.fs.AbstractPoller$Request@1492d01
at java.lang.Object.wait(Unknown Source)
at sun.nio.fs.AbstractPoller$Request.awaitResult(Unknown Source)
at sun.nio.fs.AbstractPoller.invoke(Unknown Source)
at sun.nio.fs.AbstractPoller.register(Unknown Source)
at sun.nio.fs.WindowsWatchService.register(Unknown Source)
at sun.nio.fs.WindowsPath.register(Unknown Source)
at sun.nio.fs.AbstractPath.register(Unknown Source)
at com.elsten.bliss.platform.storage.file.observer.filewatcher.FileWatcherFileSystemObserver$WatchingFileVisitor$$anonfun$preVisitDirectory.apply(FileWatcherFileSystemObserver.scala:87)
我们离开它好几个小时了,对 register
的调用没有 return。
正在观看的文件夹是通过网络在网络附加存储上使用 wifi 访问的。我知道这不太可靠,但我有很多用户有类似的配置,这是第一次被报告。
在 register
的 Javadocs 中没有提到阻塞的可能性。我真的应该在某种超时中包围这个调用吗?
感谢大家的评论。
It looks like this is a bug,并在 8u152(刚刚发布)和 Java 9.
中得到修复
我的软件用户在为文件夹添加监视时遇到问题。对 register
的调用似乎永远阻塞。这是来自用户机器的线程转储:
platformExecutor [01-12_10:14]" Id=56 WAITING on sun.nio.fs.AbstractPoller$Request@1492d01
at java.lang.Object.wait(Native Method)
- waiting on sun.nio.fs.AbstractPoller$Request@1492d01
at java.lang.Object.wait(Unknown Source)
at sun.nio.fs.AbstractPoller$Request.awaitResult(Unknown Source)
at sun.nio.fs.AbstractPoller.invoke(Unknown Source)
at sun.nio.fs.AbstractPoller.register(Unknown Source)
at sun.nio.fs.WindowsWatchService.register(Unknown Source)
at sun.nio.fs.WindowsPath.register(Unknown Source)
at sun.nio.fs.AbstractPath.register(Unknown Source)
at com.elsten.bliss.platform.storage.file.observer.filewatcher.FileWatcherFileSystemObserver$WatchingFileVisitor$$anonfun$preVisitDirectory.apply(FileWatcherFileSystemObserver.scala:87)
我们离开它好几个小时了,对 register
的调用没有 return。
正在观看的文件夹是通过网络在网络附加存储上使用 wifi 访问的。我知道这不太可靠,但我有很多用户有类似的配置,这是第一次被报告。
在 register
的 Javadocs 中没有提到阻塞的可能性。我真的应该在某种超时中包围这个调用吗?
感谢大家的评论。
It looks like this is a bug,并在 8u152(刚刚发布)和 Java 9.
中得到修复