# HG changeset patch # User chegar # Date 1425575087 0 # Node ID c4467840385788d636cdb075a820aec4d3e20b6b # Parent f32302d0ba478646cf6016f8aaa3ff1231b45979 8005226: java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java fails intermittently Reviewed-by: rriggs, smarks diff -r f32302d0ba47 -r c44678403857 jdk/test/java/rmi/testlibrary/TestLibrary.java --- a/jdk/test/java/rmi/testlibrary/TestLibrary.java Thu Mar 05 14:54:07 2015 +0100 +++ b/jdk/test/java/rmi/testlibrary/TestLibrary.java Thu Mar 05 17:04:47 2015 +0000 @@ -413,6 +413,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. diff -r f32302d0ba47 -r c44678403857 jdk/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java --- a/jdk/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java Thu Mar 05 14:54:07 2015 +0100 +++ b/jdk/test/java/rmi/transport/pinClientSocketFactory/PinClientSocketFactory.java Thu Mar 05 17:04:47 2015 +0000 @@ -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 registryRef = new WeakReference(csf); - Registry registryStub = LocateRegistry.getRegistry("", PORT, csf); + Registry registryStub = LocateRegistry.getRegistry("", port, csf); csf = null; registryStub.list(); registryStub = null;