[jboss-cvs] JBossAS SVN: r100309 - trunk/testsuite/src/main/org/jboss/test/jmx/shutdown.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Feb 2 18:43:12 EST 2010
Author: david.lloyd at jboss.com
Date: 2010-02-02 18:43:12 -0500 (Tue, 02 Feb 2010)
New Revision: 100309
Modified:
trunk/testsuite/src/main/org/jboss/test/jmx/shutdown/ExitOnShutdown.java
Log:
Attempt to avoid a possible classloading issue where the classloader is torn down before the thread starts, thus causing the thread to be unable to find java.lang.System. This is accomplished by suspending the stopService() method until the exit thread has gotten ahold of a Runtime instance upon which exit() may be called without any further class loading
Modified: trunk/testsuite/src/main/org/jboss/test/jmx/shutdown/ExitOnShutdown.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jmx/shutdown/ExitOnShutdown.java 2010-02-02 23:23:05 UTC (rev 100308)
+++ trunk/testsuite/src/main/org/jboss/test/jmx/shutdown/ExitOnShutdown.java 2010-02-02 23:43:12 UTC (rev 100309)
@@ -25,6 +25,8 @@
import org.jboss.system.ServiceMBeanSupport;
+import java.util.concurrent.CountDownLatch;
+
/** A service that calls System.exit from its stopService method. Note that
* this service cannot be deployed when the server is shutdown as its call
* to System.exit(0) will hang the vm in java.lang.Shutdown.exit as the
@@ -43,15 +45,24 @@
ctx.bind("ExitOnShutdown", Boolean.TRUE);
}
- protected void stopService() throws Exception
+ protected void stopService()
{
+ final CountDownLatch latch = new CountDownLatch(1);
Thread thread = new Thread(new Runnable()
{
public void run()
{
- System.exit(0);
+ Runtime r = Runtime.getRuntime();
+ latch.countDown();
+ r.exit(0);
}
}, "ExitOnShutdown");
thread.start();
+ for (;;) try {
+ latch.await();
+ break;
+ } catch (InterruptedException e) {
+ // eat it
+ }
}
}
More information about the jboss-cvs-commits
mailing list