changeset 11474:d215cd281678 jdk8u65-b08

8005226: java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java fails intermittently Reviewed-by: rriggs, smarks
author igerasim
date Fri, 31 Jul 2015 17:18:59 +0300
parents dbb4e2bdfa9e
children 3417c15c749b
files test/java/rmi/testlibrary/TestLibrary.java test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java
diffstat 2 files changed, 15 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/rmi/testlibrary/TestLibrary.java	Wed Jul 29 11:18:37 2015 -0700
+++ b/test/java/rmi/testlibrary/TestLibrary.java	Fri Jul 31 17:18:59 2015 +0300
@@ -383,6 +383,16 @@
     }
 
     /**
+     * Creates an RMI {@link Registry} on an ephemeral port.
+     *
+     * @returns an RMI Registry
+     * @throws RemoteException if there was a problem creating a Registry.
+     */
+    public static Registry createRegistryOnEphemeralPort() throws RemoteException {
+        return LocateRegistry.createRegistry(0);
+    }
+
+    /**
      * Returns the port number the RMI {@link Registry} is running on.
      *
      * @param registry the registry to find the port of.
--- a/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java	Wed Jul 29 11:18:37 2015 -0700
+++ b/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java	Fri Jul 31 17:18:59 2015 +0300
@@ -58,7 +58,6 @@
 
 public class PinClientSocketFactory {
 
-    private static final int PORT = TestLibrary.getUnusedRandomPort();
     private static final int SESSIONS = 50;
 
     public interface Factory extends Remote {
@@ -96,10 +95,13 @@
         }
         UnicastRemoteObject.unexportObject(factoryImpl, true);
 
-        Registry registryImpl = LocateRegistry.createRegistry(PORT);
+        Registry registryImpl = TestLibrary.createRegistryOnEphemeralPort();
+        int port = TestLibrary.getRegistryPort(registryImpl);
+        System.out.println("Registry listening on port " + port);
+
         CSF csf = new CSF();
         Reference<CSF> registryRef = new WeakReference<CSF>(csf);
-        Registry registryStub = LocateRegistry.getRegistry("", PORT, csf);
+        Registry registryStub = LocateRegistry.getRegistry("", port, csf);
         csf = null;
         registryStub.list();
         registryStub = null;