JDK-8085875 : java/net/DatagramSocket/PortUnreachable.java fails intermittently: Address already in use
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 9,10
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-06-05
  • Updated: 2024-04-23
  • Resolved: 2017-09-22
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 10
10 b25Fixed
Related Reports
Relates :  
Description
java/net/DatagramSocket/PortUnreachable.java fails intermittently with Address already in use.

----------System.err:(31/1840)----------
java.net.BindException: Address already in use
	at java.net.PlainDatagramSocketImpl.bind0(Native Method)
	at java.net.AbstractPlainDatagramSocketImpl.bind(AbstractPlainDatagramSocketImpl.java:94)
	at java.net.DatagramSocket.bind(DatagramSocket.java:394)
	at java.net.DatagramSocket.<init>(DatagramSocket.java:244)
	at java.net.DatagramSocket.<init>(DatagramSocket.java:301)
	at java.net.DatagramSocket.<init>(DatagramSocket.java:273)
	at PortUnreachable.serverSend(PortUnreachable.java:52)
	at PortUnreachable.execute(PortUnreachable.java:87)
	at PortUnreachable.main(PortUnreachable.java:101)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:502)
	at com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:218)
	at java.lang.Thread.run(Thread.java:745)
java.net.SocketTimeoutException: Receive timed out
	at java.net.PlainDatagramSocketImpl.peekData(Native Method)
	at java.net.DatagramSocket.receive(DatagramSocket.java:745)
	at PortUnreachable.execute(PortUnreachable.java:92)
	at PortUnreachable.main(PortUnreachable.java:101)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:502)
	at com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:218)
	at java.lang.Thread.run(Thread.java:745)

JavaTest Message: Test threw exception: java.net.SocketTimeoutException
JavaTest Message: shutting down test

result: Failed. Execution failed: `main' threw exception: java.net.SocketTimeoutException: Receive timed out


Comments
URL: http://hg.openjdk.java.net/jdk10/master/rev/78fd493e38bb User: xiaofeya Date: 2017-09-22 03:29:16 +0000
22-09-2017

Review thread: http://mail.openjdk.java.net/pipermail/net-dev/2017-September/010919.html Failed to push. "jdk10/jdk10" has been temporarily locked for repo consolidation work. Will do on resume
11-09-2017

Occured in Mach 5 9-dev build # 2338 Testresult: http://java.se.oracle.com/mach5//view/All/job/9-dev/2338/artifact/testresults/macosx-x64/jdk_test.tier2/JTwork/java/net/DatagramSocket/PortUnreachable.jtr/*view*/
09-05-2017

i'll take this as I modified it previously. This is a latency issue in the creation of a server socket, use it, close, and create another server socket with same port => Already in use bind exception Test is dependent on OS releasing the port and as such making it available for re-use in the test, while at the same time monotonically increasing port numbers for any new DatagramSocket using any port (if that makes sense!) So, either the OS has yet to release the port number for the server socket closed, when the server socket is re-created, or another concurrent test has managed to "steal" the test port. This is possible based on linux free port allocation algorithm.
25-06-2015