Cancelled key may fail select()

Simone Bordet simone.bordet at gmail.com
Tue Feb 11 21:36:38 UTC 2020


Hi,

looking at SelectorImpl.processDeregisterQueue(), there is an
iteration that, within the loop, may call SelChImpl.kill(), which may
throw an IOException.

If the exception is thrown, the iteration over the cancelled keys is
aborted and the exception unwinds up to a select() calls, which
basically means that the selector is now unusable as the only thing
that applications can do when select() throws is to close the
selector.

Closing the selector causes all other (perfectly working) keys to be
either closed or left lingering about.

This has been reported for example here:
https://github.com/battleblow/openjdk-jdk11u/issues/94
https://github.com/eclipse/jetty.project/issues/4418

Should not the call to kill() be wrapped in a try/catch, ignoring the
exception, and the iteration be continued?

I am an OpenJDK author and I can file a bug about this, if the issue
is confirmed.

Thanks!

-- 
Simone Bordet
---
Finally, no matter how good the architecture and design are,
to deliver bug-free software with optimal performance and reliability,
the implementation technique must be flawless.   Victoria Livschitz


More information about the nio-dev mailing list