Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8303471

(fs) Ignore polling interval sensitivity modifiers in PollingWatchService

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • core-libs
    • None
    • behavioral
    • minimal
    • Little compatibility risk as this would merely prevent setting the polling interval to a larger value which is less useful.
    • Java API
    • JDK

      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.

            bpb Brian Burkhalter
            bpb Brian Burkhalter
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: