8171142: jdk_rmi registry test fail to clean up on failure
authormli
Tue, 24 Jan 2017 00:48:51 -0800
changeset 43296 0f1ac3527db2
parent 43295 58870c7a62e0
child 43297 05ad35b943d0
8171142: jdk_rmi registry test fail to clean up on failure Reviewed-by: rriggs, dholmes
jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java
jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java
jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java
jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java
jdk/test/java/rmi/testlibrary/JavaVM.java
jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java
jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java
jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java
jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java
jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java
jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java
--- a/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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
@@ -167,7 +167,7 @@
             exception = e;
         } finally {
             if (rmid != null)
-                rmid.destroy();
+                rmid.cleanup();
         }
         if (exception != null)
             TestLibrary.bomb("\nexception thrown in test: ", exception);
--- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2017, 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
@@ -277,10 +277,14 @@
                     try {
                         Process client = new ProcessBuilder(clientProcessStr).
                                 inheritIO().start();
-                        client.waitFor();
-                        int exitValue = client.exitValue();
-                        if (0 != exitValue) {
-                            die("Error: error happened in client process, exitValue = " + exitValue);
+                        try {
+                            client.waitFor();
+                            int exitValue = client.exitValue();
+                            if (0 != exitValue) {
+                                die("Error: error happened in client process, exitValue = " + exitValue);
+                            }
+                        } finally {
+                            client.destroyForcibly();
                         }
                     } catch (IOException ex) {
                         die("Error: Unable start client process, ex=" + ex.getMessage());
--- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -75,6 +75,7 @@
         System.err.println("\nRegression test for bug 4308492\n");
 
         KeepAliveDuringCall obj = new KeepAliveDuringCall();
+        JavaVM jvm = null;
 
         try {
             UnicastRemoteObject.exportObject(obj);
@@ -88,9 +89,10 @@
             System.err.println("bound shutdown monitor in local registry");
 
             System.err.println("starting remote ShutdownImpl VM...");
-            (new JavaVM("ShutdownImpl",
+            jvm = new JavaVM("ShutdownImpl",
                         "-Drmi.registry.port=" +
-                        registryPort, "")).start();
+                        registryPort, "");
+            jvm.start();
 
             Shutdown s;
             synchronized (obj.lock) {
@@ -132,6 +134,9 @@
                     "TEST FAILED: unexpected exception", e);
             }
         } finally {
+            if (jvm != null) {
+                jvm.destroy();
+            }
             try {
                 UnicastRemoteObject.unexportObject(obj, true);
             } catch (RemoteException e) {
--- a/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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
@@ -82,6 +82,7 @@
                            String.valueOf(LEASE_VALUE));
 
         LeaseCheckInterval obj = new LeaseCheckInterval();
+        JavaVM jvm = null;
 
         try {
             UnicastRemoteObject.exportObject(obj);
@@ -96,8 +97,9 @@
 
             synchronized (obj.lock) {
                 System.err.println("starting remote client VM...");
-                (new JavaVM("SelfTerminator", "-Drmi.registry.port=" +
-                            registryPort, "")).start();
+                jvm = new JavaVM("SelfTerminator", "-Drmi.registry.port=" +
+                            registryPort, "");
+                jvm.start();
 
                 System.err.println("waiting for unreferenced() callback...");
                 obj.lock.wait(TIMEOUT);
@@ -120,6 +122,9 @@
                     "TEST FAILED: unexpected exception: " + e.toString());
             }
         } finally {
+            if (jvm != null) {
+                jvm.destroy();
+            }
             /*
              * When all is said and done, try to unexport the remote object
              * so that the VM has a chance to exit.
--- a/jdk/test/java/rmi/testlibrary/JavaVM.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/java/rmi/testlibrary/JavaVM.java	Tue Jan 24 00:48:51 2017 -0800
@@ -224,7 +224,7 @@
 
     public void destroy() {
         if (vm != null) {
-            vm.destroy();
+            vm.destroyForcibly();
         }
         vm = null;
     }
--- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
@@ -110,6 +110,7 @@
                                     String propertyValue,
                                     String extraProp)
     {
+        JavaVM jvm = null;
         try {
             String propOption = "";
             String equal = "";
@@ -119,7 +120,7 @@
             }
 
             // create a client to tell checkFQDN what its rmi name is.
-            JavaVM jvm = new JavaVM("CheckFQDNClient",
+            jvm = new JavaVM("CheckFQDNClient",
                                     propOption + property +
                                     equal +
                                     propertyValue + extraProp +
@@ -140,6 +141,10 @@
 
         } catch (Exception e) {
             TestLibrary.bomb(e);
+        } finally {
+            if (jvm != null) {
+                jvm.destroy();
+            }
         }
     }
 
--- a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2017, 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
@@ -108,8 +108,12 @@
                                         registryPort,
                                         "");
 
-                if (jvm.execute() != 0) {
-                    TestLibrary.bomb("Client process failed");
+                try {
+                    if (jvm.execute() != 0) {
+                        TestLibrary.bomb("Client process failed");
+                    }
+                } finally {
+                    jvm.destroy();
                 }
             }
             numLeft = getDGCLeaseTableSize();
--- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2017, 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
@@ -66,8 +66,11 @@
     private static Process rmiServerProcess;
 
     public static void main(String[] args) throws Exception {
-        startTestComponents();
-        stopTestComponents();
+        try {
+            startTestComponents();
+        } finally {
+            stopTestComponents();
+        }
         System.err.println("Test completed OK ");
     }
 
@@ -142,11 +145,13 @@
     }
 
     static void stopOrbd() throws Exception {
-        System.out.println("RmiIiopReturnValueTest.stopOrbd: destroy orbdProcess ");
-        orbdProcess.destroyForcibly();
-        orbdProcess.waitFor();
-        System.out.println("orbd exitCode:"
-            + orbdProcess.exitValue());
+        if (orbdProcess != null) {
+            System.out.println("RmiIiopReturnValueTest.stopOrbd: destroy orbdProcess ");
+            orbdProcess.destroyForcibly();
+            orbdProcess.waitFor();
+            System.out.println("orbd exitCode:"
+                + orbdProcess.exitValue());
+        }
     }
 
     static void executeRmiIiopClient() throws Exception {
--- a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, 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
@@ -61,8 +61,11 @@
     private static Process rmiServerProcess;
 
     public static void main(String[] args) throws Exception {
-        startTestComponents();
-        stopTestComponents();
+        try {
+            startTestComponents();
+        } finally {
+            stopTestComponents();
+        }
         System.err.println("Test completed OK ");
     }
 
@@ -124,17 +127,21 @@
     }
 
     static void stopRmiIiopServer() throws Exception {
-        rmiServerProcess.destroyForcibly();
-        rmiServerProcess.waitFor();
-        System.out.println("serverProcess exitCode:"
-            + rmiServerProcess.exitValue());
+        if (rmiServerProcess != null) {
+            rmiServerProcess.destroyForcibly();
+            rmiServerProcess.waitFor();
+            System.out.println("serverProcess exitCode:"
+                + rmiServerProcess.exitValue());
+        }
     }
 
     static void stopOrbd() throws Exception {
-        orbdProcess.destroyForcibly();
-        orbdProcess.waitFor();
-        System.out.println("orbd exitCode:"
-            + orbdProcess.exitValue());
+        if (orbdProcess != null) {
+            orbdProcess.destroyForcibly();
+            orbdProcess.waitFor();
+            System.out.println("orbd exitCode:"
+                + orbdProcess.exitValue());
+        }
     }
 
     static void executeRmiIiopClient() throws Exception {
--- a/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2017, 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
@@ -52,7 +52,11 @@
         ByteArrayOutputStream err = new ByteArrayOutputStream();
         JavaVM vm = new JavaVM(StartRegistry.class.getName(),
                                "-Dsun.rmi.transport.logLevel=v", "", out, err);
-        vm.execute();
+        try {
+            vm.execute();
+        } finally {
+            vm.destroy();
+        }
 
         String errString = err.toString();
 
--- a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java	Tue Jan 24 12:06:03 2017 +0530
+++ b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java	Tue Jan 24 00:48:51 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2017, 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
@@ -72,7 +72,11 @@
                 + " --add-exports=java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED"
                 + " -Djava.util.logging.config.file="
                 + loggingPropertiesFile, "", out, err);
-        vm.execute();
+        try {
+            vm.execute();
+        } finally {
+            vm.destroy();
+        }
 
         /*
          * Verify that the subprocess had no System.err output.