[jboss-cvs] JBossAS SVN: r71990 - trunk/server/src/main/org/jboss/ejb/plugins.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Apr 10 22:30:40 EDT 2008
Author: bstansberry at jboss.com
Date: 2008-04-10 22:30:40 -0400 (Thu, 10 Apr 2008)
New Revision: 71990
Modified:
trunk/server/src/main/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
Log:
[JBAS-5375] Don't leak TCCL to Timer thread
Modified: trunk/server/src/main/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java
===================================================================
--- trunk/server/src/main/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java 2008-04-11 02:19:58 UTC (rev 71989)
+++ trunk/server/src/main/org/jboss/ejb/plugins/LRUEnterpriseContextCachePolicy.java 2008-04-11 02:30:40 UTC (rev 71990)
@@ -21,6 +21,7 @@
*/
package org.jboss.ejb.plugins;
+import java.security.AccessController;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
@@ -33,6 +34,7 @@
import org.jboss.monitor.Monitorable;
import org.jboss.monitor.client.BeanCacheSnapshot;
import org.jboss.util.LRUCachePolicy;
+import org.jboss.util.loading.ContextClassLoaderSwitcher;
import org.w3c.dom.Element;
/**
@@ -50,9 +52,25 @@
// Attributes ----------------------------------------------------
protected static Logger log = Logger.getLogger(LRUEnterpriseContextCachePolicy.class);
- protected static Timer tasksTimer = new Timer(true);
+ protected static Timer tasksTimer;
static
{
+ // Don't leak the TCCL to the tasksTimer thread
+ ContextClassLoaderSwitcher clSwitcher = (ContextClassLoaderSwitcher) AccessController.doPrivileged(ContextClassLoaderSwitcher.INSTANTIATOR);
+ ContextClassLoaderSwitcher.SwitchContext clSwitchContext = null;
+ try
+ {
+ // Switches the TCCL to this class' classloader
+ clSwitchContext = clSwitcher.getSwitchContext(LRUEnterpriseContextCachePolicy.class.getClassLoader());
+ tasksTimer = new Timer(true);
+ }
+ finally
+ {
+ // Restores the TCCL
+ if (clSwitchContext != null)
+ clSwitchContext.reset();
+ }
+
log.debug("Cache policy timer started, tasksTimer="+tasksTimer);
}
More information about the jboss-cvs-commits
mailing list