< prev index next >

test/java/rmi/testlibrary/RMID.java

Print this page

        

*** 20,29 **** --- 20,30 ---- * or visit www.oracle.com if you need additional information or have any * questions. */ import java.io.*; + import java.net.BindException; import java.rmi.*; import java.rmi.activation.*; import java.rmi.registry.*; import java.util.concurrent.TimeoutException;
*** 40,50 **** // such as jcov.sleep.multiplier; see start(long) method. // Also consider the test.timeout.factor property (a float). 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 String SYSTEM_NAME = ActivationSystem.class.getName(); // "java.rmi.activation.ActivationSystem" public static String MANAGER_OPTION="-Djava.security.manager="; --- 41,51 ---- // such as jcov.sleep.multiplier; see start(long) method. // Also consider the test.timeout.factor property (a float). 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 = 2000L; private static final String SYSTEM_NAME = ActivationSystem.class.getName(); // "java.rmi.activation.ActivationSystem" public static String MANAGER_OPTION="-Djava.security.manager=";
*** 179,188 **** --- 180,196 ---- { super(classname, options, args, out, err); 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. */ public static void removeLog() { File f = new File(LOGDIR, log);
*** 227,236 **** --- 235,261 ---- } catch (RemoteException | NotBoundException ex) { return null; } } + 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. */ public void start() throws IOException {
*** 268,277 **** --- 293,303 ---- (System.currentTimeMillis() - startTime) + "ms."); return; } try { + checkAddressInUser(); int status = vm.exitValue(); TestLibrary.bomb("Rmid process exited with status " + status + " after " + (System.currentTimeMillis() - startTime) + "ms."); } catch (IllegalThreadStateException ignore) { }
*** 291,300 **** --- 317,327 ---- (System.currentTimeMillis() - startTime) + "ms."); return; } if (System.currentTimeMillis() > deadline) { + checkAddressInUser(); TestLibrary.bomb("Failed to start rmid, giving up after " + (System.currentTimeMillis() - startTime) + "ms.", null); } } }
< prev index next >