changeset 14664:52c05fa4079f

8157777: DeadCachedConnection doesn't wait for registry to die Reviewed-by: darcy
author smarks
date Tue, 31 May 2016 17:54:41 -0700
parents f6779ecbf3bb
children a3e5bc744553
files test/java/rmi/testlibrary/JavaVM.java test/sun/rmi/transport/tcp/DeadCachedConnection.java
diffstat 2 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test/java/rmi/testlibrary/JavaVM.java	Tue May 31 16:42:32 2016 -0700
+++ b/test/java/rmi/testlibrary/JavaVM.java	Tue May 31 17:54:41 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -166,6 +166,25 @@
     }
 
     /**
+     * Destroys the VM, waits for it to terminate, and returns
+     * its exit status.
+     *
+     * @throws IllegalStateException if the VM has already been destroyed
+     * @throws InterruptedException if the caller is interrupted while waiting
+     */
+    public int terminate() throws InterruptedException {
+        if (vm == null) {
+            throw new IllegalStateException("JavaVM already destroyed");
+        }
+
+        vm.destroy();
+        int status = waitFor();
+        vm = null;
+        return status;
+    }
+
+
+    /**
      * Waits for the subprocess to exit, joins the pipe threads to ensure that
      * all output is collected, and returns its exit status.
      */
--- a/test/sun/rmi/transport/tcp/DeadCachedConnection.java	Tue May 31 16:42:32 2016 -0700
+++ b/test/sun/rmi/transport/tcp/DeadCachedConnection.java	Tue May 31 17:54:41 2016 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
  */
 
 /* @test
- * @bug 4094891
+ * @bug 4094891 8157777
  * @summary unable to retry call if cached connection to server is used
  * @library ../../../../java/rmi/testlibrary
  * @modules java.rmi/sun.rmi.registry
@@ -123,10 +123,9 @@
     }
     private static JavaVM subreg = null;
 
-    public static void killRegistry() {
+    public static void killRegistry() throws InterruptedException {
         if (DeadCachedConnection.subreg != null) {
-            DeadCachedConnection.subreg.destroy();
-            try { Thread.sleep(2000); } catch (InterruptedException ie) {}
+            DeadCachedConnection.subreg.terminate();
         }
         DeadCachedConnection.subreg = null;
     }