Code Review Request 7142596: RMI JPRT tests are failing

Alan Bateman Alan.Bateman at oracle.com
Sat Jul 14 10:31:44 UTC 2012


On 14/07/2012 00:09, Stuart Marks wrote:
>
> There is at least one test case that wants to create two registries 
> within the same JVM. The first call to createRegistry(0) will usually 
> succeed. The second call from the same JVM will throw an 
> ExportException. So, we catch this and retry using a random port 
> instead to create the second registry. If *that* fails we give up at 
> that point instead of retrying repeatedly.
Okay, so it's the export of the object that is the issue because the 
objID is based on the argument rather than the actual port. In that case 
would it make sense to switch to the factory method that takes the 
RMIServerSocketFactory as argument, something like:

   static class ServerSocketFactory implements RMIServerSocketFactory {
     public ServerSocket createServerSocket(int port) throws IOException 
{ return new ServerSocket(0); }
   }

   static class ClientSocketFactory implements RMIClientSocketFactory {
     public Socket createSocket(String host, int port) throws 
IOException { return new Socket(host, port); }
   }

   Registry registry = LocateRegistry.createRegistry(0, new 
ClientSocketFactory(), new ServerSocketFactory());

-Alan.





More information about the core-libs-dev mailing list