Cancelled key may fail select()
Alan Bateman
Alan.Bateman at oracle.com
Tue Feb 11 22:11:37 UTC 2020
On 11/02/2020 21:36, Simone Bordet wrote:
> 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?
>
Do you have a reproducer? I assume this doesn't duplicate with JDK 13 or
newer, the reason is that the SocketChannelImpl::kill implementation
doesn't throw. There has been significant churn in this area and it
might be that a careful subset of JDK-8223353 may need to be back-ported
to the 11 updates.
-Alan
More information about the nio-dev
mailing list