8171142: jdk_rmi registry test fail to clean up on failure

Reviewed-by: rriggs, dholmes
This commit is contained in:
Hamlin Li 2017-01-24 00:48:51 -08:00
parent 861b7d08a0
commit cf31932ce4
11 changed files with 85 additions and 42 deletions

View File

@ -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);

View File

@ -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());

View File

@ -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) {

View File

@ -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.

View File

@ -224,7 +224,7 @@ public class JavaVM {
public void destroy() {
if (vm != null) {
vm.destroy();
vm.destroyForcibly();
}
vm = null;
}

View File

@ -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();
}
}
}

View File

@ -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();

View File

@ -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 {

View File

@ -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 {

View File

@ -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();

View File

@ -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.