--- old/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java 2016-09-27 02:07:59.711277263 -0700 +++ new/test/java/rmi/activation/Activatable/checkActivateRef/CheckActivateRef.java 2016-09-27 02:07:59.406429757 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4105080 + * @bug 4105080 8085192 * @summary Activation retry during a remote method call to an activatable * object can cause infinite recursion in some situations. The * RemoteRef contained in the ActivatableRef should never be @@ -117,9 +117,7 @@ TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager); // start an rmid. - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java 2016-09-27 02:08:00.755754781 -0700 +++ new/test/java/rmi/activation/Activatable/checkImplClassLoader/CheckImplClassLoader.java 2016-09-27 02:08:00.549857778 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4289544 + * @bug 4289544 8085192 * @summary ActivationGroupImpl.newInstance does not set context classloader for impl * @author Laird Dornin; code borrowed from Ann Wollrath * @@ -79,9 +79,7 @@ TestLibrary.suggestSecurityManager( TestParams.defaultSecurityManager); - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); System.err.println("Create activation group in this VM"); ActivationGroupDesc groupDesc = --- old/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java 2016-09-27 02:08:01.508378296 -0700 +++ new/test/java/rmi/activation/Activatable/checkRegisterInLog/CheckRegisterInLog.java 2016-09-27 02:08:01.218523290 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4110548 + * @bug 4110548 8085192 * @summary activate fails if rmid is restarted * @author Ann Wollrath * @@ -98,9 +98,7 @@ /* * Start up activation system daemon "rmid". */ - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java 2016-09-27 02:08:02.136064306 -0700 +++ new/test/java/rmi/activation/Activatable/createPrivateActivable/CreatePrivateActivatable.java 2016-09-27 02:08:01.959152803 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4164971 + * @bug 4164971 8085192 * @summary allow non-public activatable class and/or constructor * @author Laird Dornin * @@ -102,9 +102,7 @@ TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager); // start an rmid. - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java 2016-09-27 02:08:03.033615322 -0700 +++ new/test/java/rmi/activation/Activatable/downloadParameterClass/DownloadParameterClass.java 2016-09-27 02:08:02.812725818 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4149366 + * @bug 4149366 8085192 * @summary The class loader used to load classes for parameter types sent in * an RMI call to an activatable object should delegate to the class loader * that loaded the class of the activatable object itself, to maximize the @@ -89,9 +89,7 @@ RMID rmid = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java 2016-09-27 02:08:03.817223336 -0700 +++ new/test/java/rmi/activation/Activatable/elucidateNoSuchMethod/ElucidateNoSuchMethod.java 2016-09-27 02:08:03.548357831 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4128620 + * @bug 4128620 8085192 * @summary synopsis: NoSuchMethodError should be elucidated * @author Laird Dornin * @@ -90,9 +90,7 @@ RMID rmid = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java 2016-09-27 02:08:04.739761853 -0700 +++ new/test/java/rmi/activation/Activatable/forceLogSnapshot/ForceLogSnapshot.java 2016-09-27 02:08:04.453904848 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4173960 + * @bug 4173960 8085192 * @summary synopsis: Activatable objects cannot be restarted. * @author Laird Dornin * @@ -37,6 +37,7 @@ */ import java.io.*; +import java.net.BindException; import java.rmi.*; import java.rmi.activation.*; import java.rmi.server.*; @@ -128,10 +129,19 @@ String option = " -Dsun.rmi.activation.snapshotInterval=" + SNAPSHOT_INTERVAL; - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.addOptions(new String[] {option, "-Djava.compiler="}); - rmid.start(); + for (int i = 0; i < 20; i++) { + RMID.removeLog(); + rmid = RMID.createRMID(); + rmid.addOptions(new String[] {option, "-Djava.compiler="}); + try { + rmid.start(); + break; + } catch (BindException ex) { + System.err.format("%ncatch BindException(%s), " + + "continue to launch rmid again...%n%n", ex.getMessage()); + continue; + } + } /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java 2016-09-27 02:08:05.713274870 -0700 +++ new/test/java/rmi/activation/Activatable/inactiveGroup/InactiveGroup.java 2016-09-27 02:08:05.438412365 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4116082 + * @bug 4116082 8085192 * * @summary synopsis: rmid should not destroy group when it reports * inactiveGroup @@ -100,9 +100,7 @@ RMID rmid = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java 2016-09-27 02:08:06.605828386 -0700 +++ new/test/java/rmi/activation/Activatable/lookupActivationSystem/LookupActivationSystem.java 2016-09-27 02:08:06.374943881 -0700 @@ -23,7 +23,7 @@ /* * @test - * @bug 6245733 + * @bug 6245733 8085192 * @summary synopsis: rmid's registry's list operation doesn't include * activation system * @author Ann Wollrath @@ -54,9 +54,7 @@ RMID rmid = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); System.err.println("look up activation system"); Registry rmidRegistry = --- old/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java 2016-09-27 02:08:07.461400401 -0700 +++ new/test/java/rmi/activation/Activatable/nestedActivate/NestedActivate.java 2016-09-27 02:08:07.221520397 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4138056 + * @bug 4138056 8085192 * @summary synopsis: Activating objects from an Activatable constructor causes deadlock * @author Ann Wollrath * @@ -100,10 +100,7 @@ RMID rmid = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); - + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed */ --- old/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java 2016-09-27 02:08:08.293983916 -0700 +++ new/test/java/rmi/activation/Activatable/nonExistentActivatable/NonExistentActivatable.java 2016-09-27 02:08:08.034113911 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4115296 + * @bug 4115296 8085192 * @summary synopsis: NoSuchObjectException not thrown for non-existent * activatable objects * @author Ann Wollrath @@ -90,9 +90,7 @@ RMID rmid = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java 2016-09-27 02:08:09.109575930 -0700 +++ new/test/java/rmi/activation/Activatable/restartCrashedService/RestartCrashedService.java 2016-09-27 02:08:08.874693426 -0700 @@ -22,8 +22,7 @@ */ /* @test - * @bug 4095165 - * @bug 4140736 + * @bug 4095165 4140736 8085192 * @summary synopsis: rmid should waitFor restartable objects that crash and restart them * @author Ann Wollrath * @@ -118,9 +117,7 @@ RestartCrashedService unicastObj = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java 2016-09-27 02:08:09.817221943 -0700 +++ new/test/java/rmi/activation/Activatable/restartLatecomer/RestartLatecomer.java 2016-09-27 02:08:09.655302940 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4526514 + * @bug 4526514 8085192 * @summary rmid does not handle group restart for latecomer objects * @author Ann Wollrath * @@ -165,9 +165,7 @@ RestartLatecomer callbackObj = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/restartService/RestartService.java 2016-09-27 02:08:10.486886955 -0700 +++ new/test/java/rmi/activation/Activatable/restartService/RestartService.java 2016-09-27 02:08:10.238011450 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4095165 4321151 + * @bug 4095165 4321151 8085192 * @key intermittent * @summary synopsis: activator should restart daemon services * @author Ann Wollrath @@ -128,9 +128,7 @@ RestartService unicastObj = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); /* Cause activation groups to have a security policy that will * allow security managers to be downloaded and installed --- old/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java 2016-09-27 02:08:11.273493469 -0700 +++ new/test/java/rmi/activation/Activatable/shutdownGracefully/ShutdownGracefully.java 2016-09-27 02:08:11.108575966 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4183169 8032050 + * @bug 4183169 8032050 8085192 * @summary Minor problem with the way ReliableLog handles IOExceptions. * * @author Laird Dornin; code borrowed from Ann Wollrath @@ -37,6 +37,7 @@ * @run main/othervm/policy=security.policy/timeout=700 ShutdownGracefully */ +import java.net.BindException; import java.rmi.activation.*; import java.rmi.*; import java.util.Properties; @@ -74,21 +75,30 @@ TestLibrary.suggestSecurityManager( "java.rmi.RMISecurityManager"); - // start an rmid. - RMID.removeLog(); - rmid = RMID.createRMID(); - - // rmid needs to run with a security manager that - // simulates a log problem; rmid should also snapshot - // quickly. - rmid.addOptions(new String[] { - "-Djava.security.manager=TestSecurityManager", - "-Dsun.rmi.activation.snapshotInterval=1"}); + for (int i = 0; i < 20; i++) { + // start an rmid. + RMID.removeLog(); + rmid = RMID.createRMID(); + + // rmid needs to run with a security manager that + // simulates a log problem; rmid should also snapshot + // quickly. + rmid.addOptions(new String[] { + "-Djava.security.manager=TestSecurityManager", + "-Dsun.rmi.activation.snapshotInterval=1"}); - // rmid.addArguments(new String[] { - // "-C-Djava.rmi.server.logCalls=true"}); + // rmid.addArguments(new String[] { + // "-C-Djava.rmi.server.logCalls=true"}); - rmid.start(); + try { + rmid.start(); + break; + } catch (BindException ex) { + System.err.format("%ncatch BindException(%s), " + + "continue to launch rmid again...%n%n", ex.getMessage()); + continue; + } + } // Ensure that activation groups run with the correct // security manager. --- old/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java 2016-09-27 02:08:11.839210479 -0700 +++ new/test/java/rmi/activation/Activatable/unregisterInactive/UnregisterInactive.java 2016-09-27 02:08:11.643308476 -0700 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4115331 + * @bug 4115331 8085192 * @summary synopsis: activatable object fails to go inactive after * unregister/inactive sequence. * @author Ann Wollrath @@ -88,9 +88,7 @@ RMID rmid = null; try { - RMID.removeLog(); - rmid = RMID.createRMID(); - rmid.start(); + rmid = RMID.launch(); System.err.println("Creating descriptor"); --- old/test/java/rmi/testlibrary/JavaVM.java 2016-09-27 02:08:12.391933989 -0700 +++ new/test/java/rmi/testlibrary/JavaVM.java 2016-09-27 02:08:12.224017986 -0700 @@ -21,6 +21,7 @@ * questions. */ +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -34,15 +35,30 @@ */ public class JavaVM { - public static final long POLLTIME_MS = 100L; + static class CachedOutputStream extends OutputStream { + ByteArrayOutputStream ba; + OutputStream os; + + public CachedOutputStream(OutputStream os) { + this.os = os; + this.ba = new ByteArrayOutputStream(); + } + + public void write(int b) throws IOException { + ba.write(b); + os.write(b); + } + } + + public static final long POLLTIME_MS = 100L; protected Process vm = null; private String classname = ""; private String args = ""; private String options = ""; - private OutputStream outputStream = System.out; - private OutputStream errorStream = System.err; + private CachedOutputStream outputStream = new CachedOutputStream(System.out); + private CachedOutputStream errorStream = new CachedOutputStream(System.err); private String policyFileName = null; private StreamPipe outPipe; private StreamPipe errPipe; @@ -73,8 +89,8 @@ String options, String args, OutputStream out, OutputStream err) { this(classname, options, args); - this.outputStream = out; - this.errorStream = err; + this.outputStream = new CachedOutputStream(out); + this.errorStream = new CachedOutputStream(err); } // Prepends passed opts array to current options @@ -110,6 +126,19 @@ return TestLibrary.getExtraProperty("jcov.options",""); } + public boolean outputContains(String str) { + return outputStream.ba.toString().indexOf(str) != -1 + || errorStream.ba.toString().indexOf(str) != -1; + } + + private String outputString() { + return outputStream.ba.toString(); + } + + private String errorString() { + return errorStream.ba.toString(); + } + /** * Exec the VM as specified in this object's constructor. */ --- old/test/java/rmi/testlibrary/RMID.java 2016-09-27 02:08:12.941658999 -0700 +++ new/test/java/rmi/testlibrary/RMID.java 2016-09-27 02:08:12.736761495 -0700 @@ -22,6 +22,7 @@ */ import java.io.*; +import java.net.BindException; import java.rmi.*; import java.rmi.activation.*; import java.rmi.registry.*; @@ -42,7 +43,7 @@ private static final long TIMEOUT_SHUTDOWN_MS = 60_000L; private static final long TIMEOUT_DESTROY_MS = 10_000L; private static final long STARTTIME_MS = 15_000L; - private static final long POLLTIME_MS = 100L; + private static final long POLLTIME_MS = 2000L; private static final String SYSTEM_NAME = ActivationSystem.class.getName(); // "java.rmi.activation.ActivationSystem" @@ -145,8 +146,8 @@ * policy file. */ public static RMID createRMID() { - return createRMID(System.out, System.err, true, true, - TestLibrary.getUnusedRandomPort()); + return createRMID(System.out, System.err, true, true, + TestLibrary.getUnusedRandomPort()); } public static RMID createRMID(OutputStream out, OutputStream err, @@ -181,6 +182,13 @@ this.port = port; } + private void checkAddressInUser() throws BindException { + if (outputContains("Address already in use") + || outputContains("Port already in use")) { + throw new BindException("Address already in use at port: " + port); + } + } + /** * Removes rmid's log file directory. */ @@ -229,6 +237,23 @@ } } + public static RMID launch() throws IOException { + RMID rmid = null; + for (int i = 0; i < 20; i++) { + RMID.removeLog(); + rmid = RMID.createRMID(); + try { + rmid.start(); + break; + } catch (BindException ex) { + System.err.format("%ncatch BindException(%s), " + + "continue to launch rmid again...%n%n", ex.getMessage()); + continue; + } + } + return rmid; + } + /** * Starts rmid and waits up to the default timeout period * to confirm that it's running. @@ -270,6 +295,7 @@ } try { + checkAddressInUser(); int status = vm.exitValue(); TestLibrary.bomb("Rmid process exited with status " + status + " after " + (System.currentTimeMillis() - startTime) + "ms."); @@ -293,6 +319,7 @@ } if (System.currentTimeMillis() > deadline) { + checkAddressInUser(); TestLibrary.bomb("Failed to start rmid, giving up after " + (System.currentTimeMillis() - startTime) + "ms.", null); }