RFR: 8174819: java/nio/file/WatchService/LotsOfEvents.java fails intermittently
Alan Bateman
alanb at openjdk.java.net
Sun Sep 26 08:28:07 UTC 2021
On Sat, 25 Sep 2021 07:02:12 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:
> Can I please get a review for this test-only change that aims to fix an intermittent failure in `LotsOfEvents` testcase?
>
> As noted by Alan in the JBS issue https://bugs.openjdk.java.net/browse/JDK-8174819, the test failure is likely due to the relatively smaller poll timeout that it currently uses. IMO, this guess is proved right by the diagnostic logs that the test is currently printing, as I note in my comment in that JBS issue.
>
> The commit in this PR increases the 2 second timeout that was used (only) in the loop to 15 seconds to make it match the poll timeout that is used outside the loop. IMO, this increase in timeout shouldn't really slow down the test, since this is the "max amount of time to wait". The 13 second additional wait would ideally only show for the "last" poll where there are no more events.
>
> Additionally, this commit also adds a few more diagnostic logs for future use, if this test fails in future.
>
> Do note that there's also a `testModifyEventsQueuing` test method which too uses a 2 second timeout in a loop. I haven't touched/changed that timeout, since that test hasn't yet failed (perhaps because the number of events generated there are just 100 as against 1024 in this `testOverflowEvent` test). If at all that other test fails any time in future, we can perhaps consider increasing the timeout there too.
test/jdk/java/nio/file/WatchService/LotsOfEvents.java line 111:
> 109: while (key != null) {
> 110: List<WatchEvent<?>> events = key.pollEvents();
> 111: System.out.println("Polling retrieved " + events.size() + " events");
Minor nit, this should be "event(s)" to avoid "1 events".
test/jdk/java/nio/file/WatchService/LotsOfEvents.java line 129:
> 127: if (!key.reset())
> 128: throw new RuntimeException("Key is no longer valid");
> 129: key = watcher.poll(15, TimeUnit.SECONDS);
Seem very long but might be okay.
test/jdk/java/nio/file/WatchService/LotsOfEvents.java line 151:
> 149: Map<WatchEvent.Kind, Long> countPerEventType = events.stream()
> 150: .collect(Collectors.groupingBy(WatchEvent::kind, Collectors.counting()));
> 151: System.err.println("After extra polling, found:");
I assume the trace message at L151 is not needed. L146 will print the count and this will be followed by the count of each kind.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5693
More information about the nio-dev
mailing list