JDK-8303471 : (fs) Ignore polling interval sensitivity modifiers in PollingWatchService
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.nio
  • Priority: P4
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 21
  • Submitted: 2023-03-01
  • Updated: 2023-03-03
  • Resolved: 2023-03-03
Related Reports
CSR :  
Description
Summary
-------

`java.nio.file.Path` defines a method to register a directory with a `WatchService`. The parameters of the `register` method can include modifiers that qualify how the directory is registered. The Java platform doesn't define any standard modifiers. The `jdk.unsupported` module defines an enum with modifiers that configure the sensitivity of polling-based WatchService implementations. The enum is `com.sun.nio.file.SensitivityWatchEventModifier`. It dates from JDK 7 and is called out in JEP 260 as a critical internal API.

The WatchService implementations on Linux and Windows ignore the extended modifiers. If you invoke the `register` method with one of these modifiers then it will be ignored.

On macOS (and AIX) the polling WatchService is used. This WatchService implementation polls registered directories for changes. The values in SensitivityWatchEventModifier map to polling intervals. Configuring the polling interval was useful in the JDK 7 time frame because most machines used spinning hard disks and had slower processors than they do now. Time has moved on. In JDK 19, JDK-8285956 reduced the default polling interval, the equivalent of "high sensitivity", and back ported the chang to older releases. The result is that it's no longer interesting to use the extended enum.

The proposal in this CSR is to change the polling WatchService to ignore the extended modifiers. A related CSR has proposed to deprecate `SensitivityWatchEventModifier` for removal.

Problem
-------

Changing the polling interval is not interest/useful in modern systems.  `com.sun.nio.file.SensitivityWatchEventModifier` is proposed to be deprecated for removal in a future release.

Solution
--------

Change the polling WatchService implementation used on macOS (and AIX) to ignore the event modifiers defined in SensitivityWatchEventModifier.

Specification
-------------

No specification change.


Comments
Moving to Approved.
03-03-2023