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.
|