RFR: 8287580: (se) CancelledKeyException during channel registration

Alan Bateman alanb at openjdk.java.net
Thu Jun 2 04:59:32 UTC 2022


On Wed, 1 Jun 2022 18:32:28 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Ignore `CancelledKeyException` during registration.

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.

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

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


More information about the nio-dev mailing list