Details
Description
On Windows 2000, when attempting to connect to a service on a port where no service is running (either locally or remotely), Mina will sometimes create and open a session instead of throwing an IoException. This session is of course unusable, and when attempting to use it an exception is thrown (the following exception from Mina 0.9.4):
java.nio.channels.NotYetConnectedException
at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:129)
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:294)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoProcessor.java:480)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.doFlush(SocketIoProcessor.java:412)
at org.apache.mina.transport.socket.nio.SocketIoProcessor.access$500(SocketIoProcessor.java:41)
at org.apache.mina.transport.socket.nio.SocketIoProcessor$Worker.run(SocketIoProcessor.java:568)
This is reproducible within a few seconds with the attached test case on Windows 2000 on Mina 0.9.4 and Mina 1.0.0. I also attempted to reproduce this on Linux 2.6.17 but was unable to.
I have attached two test cases, one MinaConnectTest and one MinaConnectTest10, the former is for 0.9.4 and the latter is for 1.0.0 – the only change is the exception caught.
Though the attached test case fails uses only localhost (to avoid DNS complications), the test case also fails if a remote host is used. I tested with a remote host running Solaris 8 from a Windows client.
Lastly, netcat in a tight loop was used concurrently with the test to verify that the port was indeed refusing connections.