LRUEnterpriseContextCachePolicy leaks classloader to Timer thread
-----------------------------------------------------------------
Key: JBAS-5375
URL:
http://jira.jboss.com/jira/browse/JBAS-5375
Project: JBoss Application Server
Issue Type: Bug
Security Level: Public (Everyone can see)
Components: EJB2
Affects Versions: JBossAS-5.0.0.Beta4
Reporter: Brian Stansberry
Assigned To: Brian Stansberry
Priority: Minor
Fix For: JBossAS-5.0.0.CR1
When LRUEnterpriseContextCachePolicy loads, it creates a static ref to Timer, which
creates a Thread. A newly created thread inherits its TCCL from whatever thread created
it, so whatever deployment classloader is the TCCL when LRUEnterpriseContextCachePolicy is
loaded, that classloader get leaked to the timer thread.
This is the cause of the failure of ClassloaderLeakUnitTestCase.testSimpleEjb().
JBoss Profiler heap analysis shows the path to the static Timer ref:
!--BaseClassLoader@d279e2{vfsfile:/C:/dev/jboss/jboss-head/testsuite/output/lib/classloader-leak-ejb.jar}
!--!--FieldReference private java.lang.ClassLoader
java.lang.Thread.contextClassLoader=Thread[Timer-2,5,RMI Runtime]
!--!--!--FieldReference private java.util.TimerThread
java.util.Timer.thread=java.util.Timer@5a9fcd
!--!--!--!--StaticFieldReference protected static java.util.Timer
org.jboss.ejb.plugins.LRUEnterpriseContextCachePolicy.tasksTimer
A fix is to set the TCCL to LRUEnterpriseContextCachePolicy.class.getClassLoader() before
creating the timer, and then restoring it.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira