JDK-8234824 : java/nio/channels/SocketChannel/AdaptSocket.java fails on Windows 10
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 8,11,13,14
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows_10
  • Submitted: 2019-11-26
  • Updated: 2020-06-08
  • Resolved: 2019-12-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 14
11.0.7-oracleFixed 13.0.4Fixed 14 b26Fixed
Related Reports
Relates :  
Description
timeout: 10
Read timed out, as expected
loop: 0
Read timed out, as expected
loop: 1
Read timed out, as expected
loop: 2
Read timed out, as expected
loop: 3
Read timed out, as expected
connect failed as expected: java.net.ConnectException: Connection refused: no further information
----------System.err:(16/1027)----------
java.net.SocketTimeoutException: Connect timed out
	at java.base/sun.nio.ch.SocketChannelImpl.finishTimedConnect(SocketChannelImpl.java:1038)
	at java.base/sun.nio.ch.SocketChannelImpl.blockingConnect(SocketChannelImpl.java:1071)
	at java.base/sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:89)
	at AdaptSocket.testConnect(AdaptSocket.java:162)
	at AdaptSocket.main(AdaptSocket.java:205)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:564)
	at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:298)
	at java.base/java.lang.Thread.run(Thread.java:832)

Looks similar to JDK-8234823, adjusting the connect() timeout from 2000 to 2500 makes the test pass. 
Comments
Fix request (13u) Requesting backport to 13u for parity with 11u, applies cleanly.
08-06-2020

11u: Patch did only reach 11.0.8. I'm approving this for 11.0.7 and take care of the push.
02-03-2020

Fix Request (11u) Backport to 11u requested because it is a part of 11.0.7-oracle. Patch applies cleanly to 11u. AdaptSocket test fails on Win10 (version 1903) without this change and passes with it.
24-02-2020

URL: https://hg.openjdk.java.net/jdk/jdk/rev/721dc0c243e7 User: michaelm Date: 2019-12-03 11:57:05 +0000
03-12-2019

It's Windows 10 Professional 1803
28-11-2019

What Windows 10 version are you running in your Virtual Box? I'm thinking this might have changed in later Windows 10 versions?
27-11-2019

So, the same test passes on a very slow Virtual Box Windows 10 VM on my laptop. There is one significant config difference between the two environments. > netsh interface tcp show global Check the parameter Max SYN Retransmissions This was set to 4 on the OCI system, whereas it was only 2 on my VM. Windows waits for 500ms before retrying the connect request (yes, even in loopback on same system, when it's not likely to succeed after ECONNREFUSED). Four attempts takes 2 seconds whereas it was only 1 second on my VM, and that is fast enough for the tests in this case. Two seconds is right on the timeout limit used in the test. I just set the parameter to 2 on the OCI system, and the test passes now.
27-11-2019

We haven't seen this fail on Windows Server 2019 either, maybe something changed in Windows 10 1903?
26-11-2019

For some reason it is taking 2 seconds for the OS to reply with the connection refused error. This is the same with a native test. Will look into possible reasons why. The equivalent on a server 2016 system is 1 second. Timeouts are suspciously close to whole numbers of seconds. Sounds like it could be a security feature to prevent syn floods maybe.
26-11-2019