test/java/rmi/testlibrary/ActivationLibrary.java
Print this page
rev 11003 : 8035000: clean up ActivationLibrary.DestroyThread
*** 101,170 ****
try {
Activatable.unexportObject(remote, true);
} catch (NoSuchObjectException e) {
}
}
-
- /** cleanup after rmid */
- public static void rmidCleanup(RMID rmid) {
- if (rmid != null) {
- if (!ActivationLibrary.safeDestroy(rmid, SAFE_WAIT_TIME)) {
- TestLibrary.bomb("rmid not destroyed in: " +
- SAFE_WAIT_TIME +
- " milliseconds");
- }
- }
- RMID.removeLog();
- }
-
- /**
- * Invoke shutdown on rmid in a way that will not cause a test
- * to hang.
- *
- * @return whether or not shutdown completed succesfully in the
- * timeAllowed
- */
- private static boolean safeDestroy(RMID rmid, long timeAllowed) {
- DestroyThread destroyThread = new DestroyThread(rmid);
- destroyThread.start();
-
- try {
- destroyThread.join(timeAllowed);
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- }
-
- return destroyThread.shutdownSucceeded();
- }
-
- /**
- * Thread class to handle the destruction of rmid
- */
- private static class DestroyThread extends Thread {
- private final RMID rmid;
- private final int port;
- private boolean succeeded = false;
-
- DestroyThread(RMID rmid) {
- this.rmid = rmid;
- this.port = rmid.getPort();
- this.setDaemon(true);
- }
-
- public void run() {
- if (RMID.lookupSystem(port) != null) {
- rmid.destroy();
- synchronized (this) {
- // flag that the test was able to shutdown rmid
- succeeded = true;
- }
- mesg("finished destroying rmid");
- } else {
- mesg("tried to shutdown when rmid was not running");
- }
- }
-
- public synchronized boolean shutdownSucceeded() {
- return succeeded;
- }
- }
}
--- 101,106 ----