Re: CancelledKeyException during channel registration

2022-05-31 Thread Alan Bateman
Moving to the nio-dev list. Registration is not an atomic operation. The channel is registered (this creates the selection key) and then the key's interest set is changed. If I read your test case correctly, it is cancelling the key before the key's interest set is changed and this leads to

CancelledKeyException during channel registration

2022-05-31 Thread Gillespie, Oli
Hi, I noticed this surprising (to me) behaviour, and wonder whether it's expected or could be considered a bug. I'm not an expert in this area so apologies if this is trivial. When registering a SocketChannel with a Selector for the first time, it's possible to get a CancelledKeyException ev