8201474: (so) Socket adaptor connect(InetAddress, timeout) succeeds when connection fails

Brian Burkhalter brian.burkhalter at oracle.com
Fri Apr 13 15:17:08 UTC 2018


On Apr 12, 2018, at 5:48 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:

> This is a regression in JDK 11 where a java.net.Socket is obtained from a SocketChannel and its 2-arg connect method is used to attempt a connection and the connect fails. The implementation incorrectly sets the state to connected for this case. The 1-arg (no timeout) connect doesn't have this issue.
> 
> For the timeout case, the socket adaptor uses pollConnected. This is blocking so the poll is wrapped by beginFinishConnect/end to support interrupt and async/close. The bug is that endFinishConnect is called with completed=true when any events are polled, including error events, so the connection state is set to indicate that the connection is established. The changes are simple:
> 
> http://cr.openjdk.java.net/~alanb/8201474/webrev/index.html

I think this looks OK. However in the test, testConnect() has a ‘shouldFail’ parameter which is always passed ‘true’. Should this be remove or cases set to ‘false’ added?

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20180413/e8bfdb90/attachment.html>


More information about the nio-dev mailing list