From cf31932ce4915b9e259b68d6ce782ebac178efae Mon Sep 17 00:00:00 2001 From: Hamlin Li Date: Tue, 24 Jan 2017 00:48:51 -0800 Subject: [PATCH] 8171142: jdk_rmi registry test fail to clean up on failure Reviewed-by: rriggs, dholmes --- .../ShutdownGracefully.java | 4 +-- .../reliability/benchmark/bench/rmi/Main.java | 14 +++++---- .../KeepAliveDuringCall.java | 11 +++++-- .../LeaseCheckInterval.java | 11 +++++-- jdk/test/java/rmi/testlibrary/JavaVM.java | 2 +- .../rmi/transport/checkFQDN/CheckFQDN.java | 9 ++++-- .../checkLeaseInfoLeak/CheckLeaseLeak.java | 10 +++++-- .../8146975/RmiIiopReturnValueTest.java | 21 +++++++++----- .../ConcurrentHashMapTest.java | 29 ++++++++++++------- .../rmi/runtime/Log/4504153/Test4504153.java | 8 +++-- .../runtime/Log/6409194/NoConsoleOutput.java | 8 +++-- 11 files changed, 85 insertions(+), 42 deletions(-) diff --git a/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java b/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java index 743e2338ba5..c45d95674e6 100644 --- a/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java +++ b/jdk/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java @@ -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 @@ public class ShutdownGracefully exception = e; } finally { if (rmid != null) - rmid.destroy(); + rmid.cleanup(); } if (exception != null) TestLibrary.bomb("\nexception thrown in test: ", exception); diff --git a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java index 34cd478995e..4d8b22e17d4 100644 --- a/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java +++ b/jdk/test/java/rmi/reliability/benchmark/bench/rmi/Main.java @@ -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 @@ public class Main { 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()); diff --git a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java index 9c46f36b6cf..c82207750f3 100644 --- a/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java +++ b/jdk/test/java/rmi/server/UnicastRemoteObject/keepAliveDuringCall/KeepAliveDuringCall.java @@ -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 @@ public class KeepAliveDuringCall implements ShutdownMonitor { System.err.println("\nRegression test for bug 4308492\n"); KeepAliveDuringCall obj = new KeepAliveDuringCall(); + JavaVM jvm = null; try { UnicastRemoteObject.exportObject(obj); @@ -88,9 +89,10 @@ public class KeepAliveDuringCall implements ShutdownMonitor { 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 @@ public class KeepAliveDuringCall implements ShutdownMonitor { "TEST FAILED: unexpected exception", e); } } finally { + if (jvm != null) { + jvm.destroy(); + } try { UnicastRemoteObject.unexportObject(obj, true); } catch (RemoteException e) { diff --git a/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java b/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java index 3b61bb1f60e..3fa349fd671 100644 --- a/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java +++ b/jdk/test/java/rmi/server/Unreferenced/leaseCheckInterval/LeaseCheckInterval.java @@ -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 @@ public class LeaseCheckInterval implements Remote, Unreferenced { String.valueOf(LEASE_VALUE)); LeaseCheckInterval obj = new LeaseCheckInterval(); + JavaVM jvm = null; try { UnicastRemoteObject.exportObject(obj); @@ -96,8 +97,9 @@ public class LeaseCheckInterval implements Remote, Unreferenced { 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 @@ public class LeaseCheckInterval implements Remote, Unreferenced { "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. diff --git a/jdk/test/java/rmi/testlibrary/JavaVM.java b/jdk/test/java/rmi/testlibrary/JavaVM.java index 5c841f5426b..c2abd8be7e9 100644 --- a/jdk/test/java/rmi/testlibrary/JavaVM.java +++ b/jdk/test/java/rmi/testlibrary/JavaVM.java @@ -224,7 +224,7 @@ public class JavaVM { public void destroy() { if (vm != null) { - vm.destroy(); + vm.destroyForcibly(); } vm = null; } diff --git a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java index 359e971b002..6be0be0b402 100644 --- a/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java +++ b/jdk/test/java/rmi/transport/checkFQDN/CheckFQDN.java @@ -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 @@ public class CheckFQDN extends UnicastRemoteObject String propertyValue, String extraProp) { + JavaVM jvm = null; try { String propOption = ""; String equal = ""; @@ -119,7 +120,7 @@ public class CheckFQDN extends UnicastRemoteObject } // 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 @@ public class CheckFQDN extends UnicastRemoteObject } catch (Exception e) { TestLibrary.bomb(e); + } finally { + if (jvm != null) { + jvm.destroy(); + } } } diff --git a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java index 8e35c8b65a8..2370dcd35c4 100644 --- a/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java +++ b/jdk/test/java/rmi/transport/checkLeaseInfoLeak/CheckLeaseLeak.java @@ -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 @@ public class CheckLeaseLeak extends UnicastRemoteObject implements LeaseLeak { 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(); diff --git a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java index 38f2c519845..5cb4e0b37de 100644 --- a/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java +++ b/jdk/test/javax/rmi/PortableRemoteObject/8146975/RmiIiopReturnValueTest.java @@ -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 @@ public class RmiIiopReturnValueTest { 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 @@ public class RmiIiopReturnValueTest { } 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 { diff --git a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java index 998a66ab954..627feb94882 100644 --- a/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java +++ b/jdk/test/javax/rmi/PortableRemoteObject/ConcurrentHashMapTest.java @@ -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 @@ public class ConcurrentHashMapTest { 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 @@ public class ConcurrentHashMapTest { } 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 { diff --git a/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java b/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java index 05f1ec5ec36..8d8f824162b 100644 --- a/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java +++ b/jdk/test/sun/rmi/runtime/Log/4504153/Test4504153.java @@ -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 @@ public class Test4504153 { 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(); diff --git a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java index 438d640c4c7..4345ef81652 100644 --- a/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java +++ b/jdk/test/sun/rmi/runtime/Log/6409194/NoConsoleOutput.java @@ -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 @@ public class NoConsoleOutput { + " --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.