RFR: 8287580: (se) CancelledKeyException during channel registration [v3]
Alan Bateman
alanb at openjdk.org
Sun Jun 19 16:52:49 UTC 2022
On Thu, 9 Jun 2022 15:11:51 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:
> Either that or go with the `KeyCancelled` test for now and file a separate issue to fix / replace that.
I looked at the CancelDuringRegister test again. Two threads are racing toe cancel the key. The winner queues the cancelled key to be flushed from the Selector at the next selection operation. If the winner is the background thread spinning on `sel.keys().forEach(SelectionKey::cancel);` then there is no guarantee that the cancelled key has been removed from the Selector's key set before the next register. So that is why it register fails intermittently with CancelledKeyException. The test can be fixed by changing it to call selectNow until the key is removed.
-------------
PR: https://git.openjdk.org/jdk/pull/8978
More information about the nio-dev
mailing list