Code Review Request 7142596: RMI JPRT tests are failing

Stuart Marks stuart.marks at
Tue Jul 10 02:06:42 UTC 2012

On 7/9/12 5:04 PM, Darryl Mocek wrote:
> I originally had getUnusedRandomPort/createRegistry(randomPort), but Alan felt
> LocateRegistry.createRegistry(0) is a better choice. getUnusedRandomPort
> creates a socket to ensure the port is available, then closes it and returns
> the port number. It's possible (though unlikely) that another process will grab
> the port after closing and before createRegistry(randomPort) executes.
> LocateRegistry.createRegistry(0) ensures the registry is started on a random port.

Either call getUnusedRandomPort, which opens and closes a socket redundantly 
(with the possible risk of somebody else stealing it before the caller reopens 
it); or call createRegistry(0) which (probably) doesn't close and reopen, but 
which throws an exception you have to deal with if a registry is already 
running in this JVM. The latter is also fairly unlikely but it does occur at 
least once in the test suite. Seems to me like six of one, half a dozen of the 

Do whichever you feel makes more sense.


More information about the core-libs-dev mailing list