Uploaded image for project: 'Application Server 3  4  5 and 6'
  1. Application Server 3 4 5 and 6
  2. JBAS-5375

LRUEnterpriseContextCachePolicy leaks classloader to Timer thread

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Minor
    • JBossAS-5.0.0.CR1
    • JBossAS-5.0.0.Beta4
    • EJB2
    • None

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              bstansbe@redhat.com Brian Stansberry
              bstansbe@redhat.com Brian Stansberry
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: