8157777: DeadCachedConnection doesn't wait for registry to die
Reviewed-by: darcy
--- a/jdk/test/java/rmi/testlibrary/JavaVM.java Tue May 31 16:42:32 2016 -0700
+++ b/jdk/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/jdk/test/sun/rmi/transport/tcp/DeadCachedConnection.java Tue May 31 16:42:32 2016 -0700
+++ b/jdk/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;
}