JDK-8065076 : java/net/SocketPermission/SocketPermissionTest.java fails intermittently
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2014-11-17
  • Updated: 2016-12-21
  • Resolved: 2016-12-21
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 8 JDK 9
8u102Fixed 9Fixed
Related Reports
Relates :  
Sub Tasks
JDK-8148206 :  
Description
This failure happened once in same binaries runs with JDK 9 b38. It is an intermittent failure.

Please refer to following part of test log:
...
test SocketPermissionTest.testPositive(SocketPermissionTest$$Lambda$12/1768074411@6586498e, SocketPermissionTest$$Lambda$13/1746524665@5654da04): success
config SocketPermissionTest.setFreePort(): success
test SocketPermissionTest.testPositive(SocketPermissionTest$$Lambda$12/1768074411@6586498e, SocketPermissionTest$$Lambda$14/1730796861@247e500e): failure
java.lang.RuntimeException: java.net.BindException: Address already in use
	at SocketPermissionTest.connectDatagramSocketTest(SocketPermissionTest.java:160)
	at SocketPermissionTest.lambda$positiveProvider$4(SocketPermissionTest.java:87)
	at SocketPermissionTest$$Lambda$14/1730796861.accept(Unknown Source)
	at SocketPermissionTest.lambda$testPositive$0(SocketPermissionTest.java:62)
	at SocketPermissionTest$$Lambda$24/1669766863.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	at SocketPermissionTest.testPositive(SocketPermissionTest.java:61)
	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:498)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:84)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:714)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:901)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1231)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:127)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:111)
	at org.testng.TestRunner.privateRun(TestRunner.java:767)
	at org.testng.TestRunner.run(TestRunner.java:617)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:334)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:329)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:291)
	at org.testng.SuiteRunner.run(SuiteRunner.java:240)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1224)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1149)
	at org.testng.TestNG.run(TestNG.java:1057)
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:161)
	at com.sun.javatest.regtest.TestNGAction$TestNGRunner.main(TestNGAction.java:145)
	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:498)
	at com.sun.javatest.regtest.MainWrapper$MainThread.run(MainWrapper.java:94)
	at java.lang.Thread.run(Thread.java:745)
Caused by: 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 SocketPermissionTest.connectDatagramSocketTest(SocketPermissionTest.java:154)
Comments
Closed this and filed a new issue JDK-8171827
21-12-2016

This test was observed to fail intermittently on Mach 5 on or around 12/20/16. See builds 1696, 1697 and 1701.
21-12-2016

In many of the test scenarios the ���listening��� socket can be created before the specific access control context and associated permission are created. The test has been rewritten to do just this, but kept the same test scenarios. The use of data providers was cute, but not workable since there is no common supertype for the socket classes. The test providers have been expanded out, keeping the same scenarios. This gives the same test coverage, but should be stable since it creates the sockets first, on an ephemeral port, and then constructs the permissions appropriately given that port.
26-01-2016

Talked to Amanda, this test should be able to replace to create server socket by ephemeral port.
22-04-2015

I will be on vacation on April 22- April 30, will start fixing this issue when I come back, set the due date on May 12, 2015
20-04-2015

You can fix this according Stuart's comments
20-04-2015

This test uses Utils.getFreePort(), which follows the open-close-reopen antipattern. That's probably what causes the intermittent BindExceptions. Test needs to be restructured to avoid that.
02-04-2015

RULE java/net/SocketPermission/SocketPermissionTest.java Exception java.lang.Exception: failures: ... RULE java/net/SocketPermission/SocketPermissionTest.java Exception java.lang.RuntimeException: java.net.BindException: Address already in use: Cannot bind RULE java/net/SocketPermission/SocketPermissionTest.java Exception java.net.BindException: Address already in use: Cannot bind
16-02-2015