8166763: java/rmi/* tests fail intermittently with "Port already in use" in RMID.start()
authormli
Mon, 12 Dec 2016 17:29:46 -0800
changeset 42667 e058e6cdb4cf
parent 42502 cf139f925da0
child 42668 9518a1858a96
8166763: java/rmi/* tests fail intermittently with "Port already in use" in RMID.start() Reviewed-by: chegar
jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java
jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/rmid.security.policy
jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java
jdk/test/java/rmi/activation/ActivationSystem/activeGroup/rmid.security.policy
jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java
jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java
jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/rmid.security.policy
jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java
jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy
jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java
jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/rmid.security.policy
--- a/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java	Mon Dec 12 17:29:46 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -36,7 +36,8 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary RMID ActivationLibrary
+ *          java.base/sun.nio.ch
+ * @build TestLibrary RMID ActivationLibrary RMIDSelectorProvider
  *     DownloadActivationGroup MyActivationGroupImpl DownloadActivationGroup_Stub
  * @run main/othervm/policy=security.policy/timeout=240 DownloadActivationGroup
  */
@@ -123,7 +124,7 @@
              * Start rmid.
              */
             RMID.removeLog();
-            rmid = RMID.createRMID();
+            rmid = RMID.createRMIDOnEphemeralPort();
             String execPolicyOption = "-Dsun.rmi.activation.execPolicy=none";
             rmid.addOptions(new String[] { execPolicyOption });
             rmid.start();
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/rmid.security.policy	Mon Dec 12 17:29:46 2016 -0800
@@ -0,0 +1,7 @@
+grant {
+    permission java.lang.RuntimePermission "selectorProvider";
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
+};
--- a/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java	Mon Dec 12 17:29:46 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,8 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary RMID ActivationLibrary
+ *          java.base/sun.nio.ch
+ * @build TestLibrary RMID ActivationLibrary RMIDSelectorProvider
  * @run main/othervm/policy=security.policy/timeout=480 IdempotentActiveGroup
  */
 
@@ -63,7 +64,7 @@
 
         try {
             RMID.removeLog();
-            rmid = RMID.createRMID();
+            rmid = RMID.createRMIDOnEphemeralPort();
             rmid.start();
 
             System.err.println("Create group descriptor");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/activation/ActivationSystem/activeGroup/rmid.security.policy	Mon Dec 12 17:29:46 2016 -0800
@@ -0,0 +1,7 @@
+grant {
+    permission java.lang.RuntimePermission "selectorProvider";
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
+};
--- a/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java	Mon Dec 12 17:29:46 2016 -0800
@@ -110,7 +110,7 @@
 
         try {
             RMID.removeLog();
-            rmid = RMID.createRMID();
+            rmid = RMID.createRMIDOnEphemeralPort();
             rmid.start();
 
             /*
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java	Mon Dec 12 17:29:46 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,8 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary RMID ActivationLibrary
+ *          java.base/sun.nio.ch
+ * @build TestLibrary RMID ActivationLibrary RMIDSelectorProvider
  *     CanCreateStubs StubClassesPermitted_Stub
  * @run main/othervm/java.security.policy=security.policy/secure=java.lang.SecurityManager/timeout=240 StubClassesPermitted
  */
@@ -98,7 +99,7 @@
 
             // start an rmid.
             RMID.removeLog();
-            rmid = RMID.createRMID();
+            rmid = RMID.createRMIDOnEphemeralPort();
             rmid.start();
 
             //rmid.addOptions(new String[] {"-C-Djava.rmi.server.logCalls=true"});
--- a/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/rmid.security.policy	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/rmid.security.policy	Mon Dec 12 17:29:46 2016 -0800
@@ -4,4 +4,9 @@
 
     // test needs to export a set of internal APIs to access them from unamed module
     permission com.sun.rmi.rmid.ExecOptionPermission "*";
+    permission java.lang.RuntimePermission "selectorProvider";
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
 };
--- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java	Mon Dec 12 17:29:46 2016 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,7 +32,8 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary RMID ActivationLibrary ActivateMe
+ *          java.base/sun.nio.ch
+ * @build TestLibrary RMID ActivationLibrary ActivateMe RMIDSelectorProvider
  * @run main/othervm/policy=security.policy UnregisterGroup
  */
 
@@ -76,7 +77,7 @@
 
         try {
             RMID.removeLog();
-            rmid = RMID.createRMID();
+            rmid = RMID.createRMIDOnEphemeralPort();
             rmid.start();
 
             /* Cause activation groups to have a security policy that will
--- a/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy	Mon Dec 12 17:29:46 2016 -0800
@@ -1,4 +1,9 @@
 grant {
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.manager=default";
     permission com.sun.rmi.rmid.ExecOptionPermission "-Djava.security.policy=*";
+    permission java.lang.RuntimePermission "selectorProvider";
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
 };
--- a/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java	Wed Jul 05 22:34:05 2017 +0200
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java	Mon Dec 12 17:29:46 2016 -0800
@@ -32,7 +32,8 @@
  *          java.rmi/sun.rmi.server
  *          java.rmi/sun.rmi.transport
  *          java.rmi/sun.rmi.transport.tcp
- * @build TestLibrary Echo EchoImpl EchoImpl_Stub
+ *          java.base/sun.nio.ch
+ * @build TestLibrary Echo EchoImpl EchoImpl_Stub RMIDSelectorProvider
  * @run main/othervm/policy=security.policy/timeout=360 UseCustomSocketFactory
  */
 
@@ -61,7 +62,7 @@
         RMID rmid = null;
 
         try {
-            rmid = RMID.createRMID();
+            rmid = RMID.createRMIDOnEphemeralPort();
             rmid.addArguments(new String[] {
                 "-C-Djava.security.policy=" +
                     TestParams.defaultGroupPolicy +
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/rmid.security.policy	Mon Dec 12 17:29:46 2016 -0800
@@ -0,0 +1,7 @@
+grant {
+    permission java.lang.RuntimePermission "selectorProvider";
+    permission java.lang.RuntimePermission "accessClassInPackage.sun.nio.ch";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.port", "read";
+    permission java.util.PropertyPermission "test.java.rmi.testlibrary.RMIDSelectorProvider.timeout", "read";
+    permission java.net.SocketPermission "*:1024-", "listen,resolve,connect,accept";
+};