pjfanning opened a new pull request, #1882:
URL: https://github.com/apache/pekko-connectors/pull/1882

   ### Motivation
   `DirectoryChangesSource` passed 
`com.sun.nio.file.SensitivityWatchEventModifier.HIGH` when registering its 
`WatchKey`. The class is terminally deprecated since JDK 21 and compiling it 
fails under `-Werror` on JDK 21+ (#296): besides the `[removal]` lint warning 
(which `@SuppressWarnings` can silence), javac emits an unsuppressable 
*"SensitivityWatchEventModifier is internal proprietary API and may be removed 
in a future release"* warning on both the import and the usage — no annotation 
placement can get past `-Werror`. It also affects users of the module system, 
and the class may be removed from the JDK at any time.
   
   The modifier is a no-op on every JDK this project supports (build baseline 
is `-release:17`), verified against the OpenJDK sources:
   - JDK 17–20: `PollingWatchService.DEFAULT_POLLING_INTERVAL` is already 2s — 
identical to what `HIGH` selected. The 10s default that made `HIGH` worthwhile 
("the service is useless on OSX without it") existed only up to JDK 11.
   - JDK 21+: the polling service ignores sensitivity modifiers altogether and 
the interval is hardcoded to 2s (JDK-8307097).
   
   ### Modification
   Remove the modifier from the `register` call, along with the import and the 
now-unneeded `@SuppressWarnings({"deprecation", "removal"})` annotation. A 
short comment explains why no sensitivity modifier is needed. This was the only 
reference in the repository. Formatted with `sbt javafmtAll` on JDK 17.
   
   ### Result
   The file module compiles warning-free with `-Xlint:deprecation -Werror` on 
JDK 21, with no behavior change on any supported JDK, and the code is immune to 
the class's eventual removal from the JDK.
   
   A possible follow-up is re-enabling the commented-out `-Xlint:removal` in 
`project/Common.scala`, after sweeping the other modules for removal warnings.
   
   ### Tests
   - `sbt file/test` — 79/79 pass on JDK 17 and on JDK 21 (the 
directory-watching specs exercise the changed registration path).
   - `javac -Xlint:deprecation -Werror` (JDK 21) on the changed file against 
the module classpath compiles clean; the previous version emits the 
internal-proprietary-API warning.
   
   ### References
   Fixes #296


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to