java.io.IOException: A non-blocking socket operation could not be completed immediately
Alan Bateman
Alan.Bateman at oracle.com
Wed Jun 6 09:33:41 UTC 2018
Moving this mail to nio-dev.
Simone - one thing to point out is that the SO_LINGER option is only
specified for sockets that are configured blocking. Here's the relevant
paragraph from the StandardSocketOption#SO_LINGER javadoc
"This socket option is intended for use with sockets that are configured
in blocking mode only. The behavior of the close method when this option
is enabled on a non-blocking socket is not defined."
The implementation has changed in JDK 11 so that SocketChannel close
disables SO_LINGER when it's enabled with a value other than 0 and the
channel is registered with a Selector. The eventual close will happen
when the channel is flushed from the Selector (the stack trace in your
bug report) but it won't hit this issue because SO_LINGER will be disabled.
-Alan
On 06/06/2018 09:35, Simone Bordet wrote:
> Resend with proper subject, doh.
>
> ---------- Forwarded message ----------
> From: Simone Bordet <simone.bordet at gmail.com>
> Date: Wed, Jun 6, 2018 at 10:29 AM
> Subject:
> To: "net-dev at openjdk.java.net >> OpenJDK Network Dev list"
> <net-dev at openjdk.java.net>
>
>
> Hi,
>
> we have stumbled upon the error below on Windows.
>
> We suspect this is happening when closing sockets that have the linger
> option set.
>
> Since SocketDispatcher.close0() eventually calls the Windows API
> closesocket(), this seems to be confirmed by this article:
> https://msdn.microsoft.com/en-us/library/windows/desktop/ms737582(v=vs.85).aspx
>
> I was wondering if this is a known issue, or anyone encountered this
> error before.
>
> For more context, see also https://github.com/eclipse/jetty.project/issues/2468.
>
> Thanks !
>
>
> java.io.IOException: A non-blocking socket operation could not be
> completed immediately
> at sun.nio.ch.SocketDispatcher.close0(Native Method)
> at sun.nio.ch.SocketDispatcher.close(SocketDispatcher.java:63)
> at sun.nio.ch.SocketChannelImpl.kill(SocketChannelImpl.java:879)
> at sun.nio.ch.WindowsSelectorImpl.implDereg(WindowsSelectorImpl.java:588)
> at sun.nio.ch.SelectorImpl.processDeregisterQueue(SelectorImpl.java:149)
> at sun.nio.ch.WindowsSelectorImpl.doSelect(WindowsSelectorImpl.java:142)
> at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:86)
> at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:97)
> at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:101)
>
> --
> 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