RFR: 8287580: (se) CancelledKeyException during channel registration [v3]

Brian Burkhalter bpb at openjdk.java.net
Thu Jun 2 22:14:33 UTC 2022


On Thu, 2 Jun 2022 18:23:59 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

>> test/jdk/java/nio/channels/Selector/KeyCancelled.java line 67:
>> 
>>> 65:                     c.register(s, SelectionKey.OP_READ);
>>> 66:                     // c.isRegistered() is false here after the exceptional case
>>> 67:                 }
>> 
>> This tries to create 10k SocketChannels. I would be concerned with the robustness of this test. I suspect it should be possible to create the conditions for the bug with just one socket channel where the registration key is flushed from the Selector in the loop, the next registration will create a new key that can be cancelled asynchronously by the other thread.
>
> Commit 925336449bfda90791b7e289d0008da4a9bc87a6 changes the test to use a single `SocketChannel`.

Commit 98bcd22e8ba60c7499fab332f943616bb88b03f5 reduces the number of `SocketChannels` created per invocation of `test()` to 5. With this change, a run of 5 test repeats in the test harness had these failure rates:

5/5 failures linux-aarch64
4/5 failures linux-x64
4/5 failures macosx-x64
3/4 failures windows-x64

This looks sufficient to detect a failure but with a much lower number of open sockets.

-------------

PR: https://git.openjdk.java.net/jdk/pull/8978


More information about the nio-dev mailing list