# HG changeset patch # User smarks # Date 1464742481 25200 # Node ID 280093905c75d56ab4250e1b4070179f3be44b43 # Parent 2956ccc7cb77d8606e6e89c9d9bb92e2688aadc4 8157777: DeadCachedConnection doesn't wait for registry to die Reviewed-by: darcy diff -r 2956ccc7cb77 -r 280093905c75 jdk/test/java/rmi/testlibrary/JavaVM.java --- 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. */ diff -r 2956ccc7cb77 -r 280093905c75 jdk/test/sun/rmi/transport/tcp/DeadCachedConnection.java --- 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; }