changeset 16252:b6d62dc38c36

8166763: java/rmi/* tests fail intermittently with "Port already in use" in RMID.start() Reviewed-by: chegar
author mli
date Mon, 12 Dec 2016 17:29:46 -0800
parents 5a846396a24c
children 095c2e4f00c1
files test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java test/java/rmi/activation/ActivationGroup/downloadActivationGroup/rmid.security.policy test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java test/java/rmi/activation/ActivationSystem/activeGroup/rmid.security.policy test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java test/java/rmi/activation/ActivationSystem/stubClassesPermitted/rmid.security.policy test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/rmid.security.policy
diffstat 11 files changed, 51 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/rmi/activation/ActivationGroup/downloadActivationGroup/DownloadActivationGroup.java	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/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/test/java/rmi/activation/ActivationSystem/activeGroup/IdempotentActiveGroup.java	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/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/test/java/rmi/activation/ActivationSystem/modifyDescriptor/ModifyDescriptor.java	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/StubClassesPermitted.java	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/test/java/rmi/activation/ActivationSystem/stubClassesPermitted/rmid.security.policy	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/test/java/rmi/activation/ActivationSystem/unregisterGroup/UnregisterGroup.java	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/test/java/rmi/activation/ActivationSystem/unregisterGroup/rmid.security.policy	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/test/java/rmi/server/RMISocketFactory/useSocketFactory/activatable/UseCustomSocketFactory.java	Mon Dec 12 16:45:08 2016 -0800
+++ b/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/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";
+};