Uploaded image for project: 'EJB 3.0'
  1. EJB 3.0
  2. EJBTHREE-1653

Locking in EJBContainer during start/stop can cause deadlocks and/or IllegalMonitorStateExceptions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 1.0.0-Beta12
    • 1.0.0-Beta11, 1.0.0-Beta12, 1.1.0
    • core
    • None

      This relates to the fix implemented for http://jira.jboss.com/jira/browse/EJBTHREE-1116

      The locking/unlocking performed during create/start/stop uses a ReentrantReadWrite lock which assumes that the lifecycle events are called by the same thread. This is not a safe assumption.

      If EJBContainer is stopped and restarted by different threads, start() will throw an IllegalMonitorStateException when it tries to unlock the write lock acquired in stop().
      Additionally, if EJBContainer is stopped, and a second thread tries to stop it again, that thread will block until it is interrupted.
      Since EJBContainer is the only object capable of acquiring the container write lock, the write lock should always be reentrant regardless of thread ownership.

            pferraro@redhat.com Paul Ferraro
            pferraro@redhat.com Paul Ferraro
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: