test/java/rmi/activation/CommandEnvironment/SetChildEnv.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1998, 2000, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 1998, 2012, 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 * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 51,85 **** public class SetChildEnv { public static void main(String argv[]) throws Exception { System.out.println("java.compiler=" + System.getProperty("java.compiler")); // don't embed spaces in any of the test args/props, because // they won't be parsed properly ! runwith (new String[0], new String[0]); runwith ( new String[] { "-verbosegc" }, new String[] { "foo.bar=SetChildEnvTest", ! "sun.rmi.server.doSomething=true" } ); runwith ( new String[] { }, ! new String[] { "parameter.count=zero" } ); runwith ( new String[] { "-Xmx32m" }, ! new String[] { } ); } private static void runwith( String[] params, // extra args ! String[] props // extra system properties ) throws Exception { TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager); --- 51,91 ---- public class SetChildEnv { public static void main(String argv[]) throws Exception { + int runningPort = TestLibrary.getUnusedRandomPort(); + System.out.println("java.compiler=" + System.getProperty("java.compiler")); // don't embed spaces in any of the test args/props, because // they won't be parsed properly ! runwith (new String[0], new String[0], runningPort); runwith ( new String[] { "-verbosegc" }, new String[] { "foo.bar=SetChildEnvTest", ! "sun.rmi.server.doSomething=true" }, ! runningPort ); runwith ( new String[] { }, ! new String[] { "parameter.count=zero" }, ! runningPort ); runwith ( new String[] { "-Xmx32m" }, ! new String[] { }, ! runningPort ); } private static void runwith( String[] params, // extra args ! String[] props, // extra system properties ! int port // port on which to communicate ) throws Exception { TestLibrary.suggestSecurityManager(TestParams.defaultSecurityManager);
*** 87,97 **** // the debugExec line while teeing to System.err DebugExecWatcher watcher = DebugExecWatcher.makeWithPipe(); RMID.removeLog(); RMID rmid = RMID.createRMID(watcher.otherEnd(), watcher.otherEnd(), ! true); // debugExec turned on rmid.start(); // compile props Properties p = new Properties(); --- 93,104 ---- // the debugExec line while teeing to System.err DebugExecWatcher watcher = DebugExecWatcher.makeWithPipe(); RMID.removeLog(); RMID rmid = RMID.createRMID(watcher.otherEnd(), watcher.otherEnd(), ! true, // debugExec turned on ! true, port); rmid.start(); // compile props Properties p = new Properties();
*** 193,203 **** if (doctor instanceof Retireable) ((Retireable)doctor).retire(); actsys.unregisterGroup(gid); Thread.sleep(5000); ! rmid.destroy(); } public static class DebugExecWatcher extends Thread { --- 200,210 ---- if (doctor instanceof Retireable) ((Retireable)doctor).retire(); actsys.unregisterGroup(gid); Thread.sleep(5000); ! ActivationLibrary.rmidCleanup(rmid); } public static class DebugExecWatcher extends Thread {
*** 241,254 **** --- 248,273 ---- while ((line = str.readLine()) != null) { this.notifyLine(line); System.err.println(line); } } catch (IOException e) { + /* During termination of distant rmid, StreamPipes will be broken when + * distant vm terminates. A "Pipe broken" exception is expected because + * DebugExecWatcher points to the same streams as StreamPipes used by RMID. + * If we get this exception. We just terminate the thread. + */ + if (e.getMessage().equals("Pipe broken")) { + try { + str.close(); + } catch (IOException ioe) {} + } + else { e.printStackTrace(); } } } + } } /* code graveyard