JDK-8157777 : TEST_BUG: DeadCachedConnection doesn't wait for registry to die
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.rmi
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2016-05-25
  • Updated: 2017-05-19
  • Resolved: 2016-06-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b122Fixed
Related Reports
Relates :  
Description
The test
sun/rmi/transport/tcp/DeadCachedConnection.java
gets an unused port, starts a registory (in a vm), ping the registry, kills it then restarts it.
When this test is run on a mac test machine (in the Mach 5 mesos pool), the ports are not release soon enough for the restart and this fail every time with a port already in use error.
A small sleep between killing and restarting the registry (I arbitrarily put in a 5 second sleep) allows this to pass.
        // Kill and restart the registry
        System.err.println("Killing registry...");
        DeadCachedConnection.killRegistry();
        System.err.println("sleeping 5 seconds...");
        Thread.sleep (5000);
        System.err.println("Restarting registry...");
        DeadCachedConnection.makeRegistry(regport);
This test passes on mac in mach5 which does not use Mesos, but since we're heading that way for resource sharing, I think this would be a good idea to do now.
Comments
Adding a sleep will probably help. A deeper problem is that this code "destroys" the registry subprocess, which merely sends it a signal. It doesn't wait for the process to exit. The RMI test library should have another method, e.g. terminate(), that destroys the subprocess and then waits for its exit status and also joins the pipe threads. See JavaVM.waitFor().
25-05-2016

JAVAVM: command = [/scratch/jenkins/workspace/9-dev/jdk/bin/java, -ea, -esa, -Xmx512m, sun.rmi.registry.RegistryImpl, 53402] Locating just-started registry... Connecting to registry... Killing registry... Restarting registry... JAVAVM: command = [/scratch/jenkins/workspace/9-dev/jdk/bin/java, -ea, -esa, -Xmx512m, sun.rmi.registry.RegistryImpl, 53402] java.rmi.server.ExportException: Port already in use: 53402; nested exception is: java.net.BindException: Address already in use at sun.rmi.transport.tcp.TCPTransport.listen(java.rmi@9-ea/TCPTransport.java:335) at sun.rmi.transport.tcp.TCPTransport.exportObject(java.rmi@9-ea/TCPTransport.java:243) at sun.rmi.transport.tcp.TCPEndpoint.exportObject(java.rmi@9-ea/TCPEndpoint.java:411) at sun.rmi.transport.LiveRef.exportObject(java.rmi@9-ea/LiveRef.java:147) at sun.rmi.server.UnicastServerRef.exportObject(java.rmi@9-ea/UnicastServerRef.java:209) at sun.rmi.registry.RegistryImpl.setup(java.rmi@9-ea/RegistryImpl.java:157) at sun.rmi.registry.RegistryImpl.<init>(java.rmi@9-ea/RegistryImpl.java:142) at sun.rmi.registry.RegistryImpl$5.run(java.rmi@9-ea/RegistryImpl.java:412) at sun.rmi.registry.RegistryImpl$5.run(java.rmi@9-ea/RegistryImpl.java:410) at java.security.AccessController.doPrivileged(java.base@9-ea/Native Method) at sun.rmi.registry.RegistryImpl.main(java.rmi@9-ea/RegistryImpl.java:409) Caused by: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(java.base@9-ea/Native Method) at java.net.AbstractPlainSocketImpl.bind(java.base@9-ea/AbstractPlainSocketImpl.java:442) at java.net.ServerSocket.bind(java.base@9-ea/ServerSocket.java:376) at java.net.ServerSocket.<init>(java.base@9-ea/ServerSocket.java:238) at java.net.ServerSocket.<init>(java.base@9-ea/ServerSocket.java:130) at sun.rmi.transport.tcp.TCPDirectSocketFactory.createServerSocket(java.rmi@9-ea/TCPDirectSocketFactory.java:45) at sun.rmi.transport.tcp.TCPEndpoint.newServerSocket(java.rmi@9-ea/TCPEndpoint.java:666) at sun.rmi.transport.tcp.TCPTransport.listen(java.rmi@9-ea/TCPTransport.java:324) ... 10 more
25-05-2016