Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-3831

Potential for deadlock using ThreadlocalPool if EJB ctor takes a lock

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • TBD EAP 5
    • EAP 5.0.0
    • EJB
    • None
    • Workaround Exists
    • Hide

      Switch to InfinitePool (or StrictMaxPool) instead

      Show
      Switch to InfinitePool (or StrictMaxPool) instead
    • Not Required

    Description

      ThreadlocalPool synchronizes on the backing pool while creating a new EJB instance, which isn't really necessary, and this can potentially lead to a deadlock if the EJB's constructor involves any other locks and something holding that lock tried to get a EJB instance from the pool. For example this can occur if the EJB constructor looks up an object using Spring, and another thread is already accessing the Spring ApplicationContext and it needs to get an EJB from the pool.

      While ThreadlocalPool can't cause any problems by itself, it requires certain behaviour from the end-user code, it would be nice is it could avoid the problem.

      ThreadlocalPool does three types of operations inside the "synchronized (this.pool)" block, which I believe dont't actually require it:

      • Calls get/set on currentBeanContext - a ThreadLocal instance it is already thread-safe
      • Uses the inUse variable - this could be replaces with an AtomicInteger since it does not need to remain consistent with the EJB instances
      • Calls to create() and destroy() - these are not protected by a synchronisation block in other implementations, so is presumably unnecessary

      Attachments

        Issue Links

          Activity

            People

              rhn-engineering-cdewolf Carlo de Wolf
              rhn-support-jlivings James Livingston (Inactive)
              Jared Morgan Jared Morgan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: