RFR: 8287168: (fs) WatchService leaves thread running if not closed
Daniel Jeliński
djelinski at openjdk.java.net
Thu Jun 2 14:10:33 UTC 2022
On Thu, 2 Jun 2022 02:52:55 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Add a `Cleaner` to each `WatchService` implementation.
The cleaners will never be invoked.
`Poller` class is kept alive by a thread, and while the class is static, it holds a hard reference to the enclosing WatchService. See [Windows](https://github.com/openjdk/jdk/blob/8323d9a8e0fa99947bb2a34b6b76bfecb0861b67/src/java.base/windows/classes/sun/nio/fs/WindowsWatchService.java#L320) / [Linux](https://github.com/openjdk/jdk/blob/8323d9a8e0fa99947bb2a34b6b76bfecb0861b67/src/java.base/linux/classes/sun/nio/fs/LinuxWatchService.java#L207)
A test checking if `WeakReference`s to `WatchService`s are cleared during GC would probably catch that.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8986
More information about the nio-dev
mailing list