SocketChannel.close() is not closing the underlying
socket when the channel is non blocking and registered with a
Selector. [See comments for simple test case]
The problem seems to be in the socket pre/post close logic
and there are actually a couple of bugs I believe.
1. On Unix the dummy version of NativeDispatcher.preClose()
is being called instead of the one in FileDispatcher. This
is because SocketDispatcher extends NativeDispatcher instead
of FileDispatcher. So, if you make SocketDispatcher extend
FileDispatcher, this fixes the problem on Unix.
2. The problem also happens on Windows, presumably because the
actual socket close should be happening (but is not) in the preClose()
function.
Strangely, this seems to be a long standing issue. I can reproduce with
every release back to 1.4.0.
socket when the channel is non blocking and registered with a
Selector. [See comments for simple test case]
The problem seems to be in the socket pre/post close logic
and there are actually a couple of bugs I believe.
1. On Unix the dummy version of NativeDispatcher.preClose()
is being called instead of the one in FileDispatcher. This
is because SocketDispatcher extends NativeDispatcher instead
of FileDispatcher. So, if you make SocketDispatcher extend
FileDispatcher, this fixes the problem on Unix.
2. The problem also happens on Windows, presumably because the
actual socket close should be happening (but is not) in the preClose()
function.
Strangely, this seems to be a long standing issue. I can reproduce with
every release back to 1.4.0.
- relates to
-
JDK-6215050 (so) SocketChannel created in CLOSE_WAIT and never cleaned up.. File Descriptor leak
- Resolved
-
JDK-6379892 Remove @ignore from test since prerequisite is fixed
- Resolved
-
JDK-6346658 (se) Selector briefly spins when asynchronously closing a registered channel [win]
- Closed
-
JDK-7130796 (se) Selector.select may hang due to asynchronous close of socket in poll array [win]
- Closed
-
JDK-4957695 URLJarFile.retrieve does not delete tmpFile on IOException
- Resolved