RFR: 8297275: WatchService delay with PollingWatchService causes test failures
Tyler Steele
tsteele at openjdk.org
Tue Nov 22 17:46:27 UTC 2022
On Fri, 21 Oct 2022 21:43:25 GMT, Tyler Steele <tsteele at openjdk.org> wrote:
> This minor change fixes a compliance test failure which was partially addressed by https://github.com/openjdk/jdk/commit/1bb4de2e2868a539846ec48dd43fd623c2ba69a5. However the failure was still observed on select machines. This change addresses the remaining failures by ensuring that any new WatchKey is held until the polling thread becomes active.
The failing test is register_and_poll in JCK17. The JCK is copyrighted, so I'm not able to post about it publicly, but I believe you should have access to it.
Currently, PollingWatchService is used only on BSD/Macos and AIX. I don't believe the issue is platform specific. I think the issue that I describe below is extant on all platforms that use PollingWatchService, but some amount of platform specificity may make it more prominent on AIX.
> I think you mean "valid" rather than "active".
I meant active, but it's probably not clear what I meant by that. What I meant to say is that there is an 'activation window' in the code without this change. The window starts when [the call](https://github.com/openjdk/jdk/blob/0ac5b55311222d0531c9cfcec8c74932661b1750/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java#L317) to `scheduleAtFixedRate(POLLING_INIT_DELAY...)`, completes and ends when the first run of the [WatchKey `poll()`](https://github.com/openjdk/jdk/blob/0ac5b55311222d0531c9cfcec8c74932661b1750/src/java.base/share/classes/sun/nio/fs/PollingWatchService.java#L342) method happens.
What the delay in this change is intended to do, is eliminate this 'activation window'. It does this by forcing register to wait for POLLING_INIT_DELAY to ensure the polling thread is running when it returns. My comment was meant to suggest, that a key should be "activ[ly]" polling for changes when it is returned by `register(...)`. POLLING_INIT_DELAY is an upper bound on the length of this 'activation window'.
I agree with your sentiment that adding a delay is not the most elegant solution. If you agree that changing POLLING_INIT_DELAY to 0 and removing the proposed delay is a good option, I am happy to run the test with that change to confirm that is a viable solution, and modify this PR.
-------------
PR: https://git.openjdk.org/jdk/pull/10824
More information about the nio-dev
mailing list