Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1159

Deadlock between Weld AbstractContext session/application contexts creationLock

XMLWordPrintable

    • Hide

      1. deploy the attached WELD-1159.war
      2. go to http://127.0.0.1:8080/WELD-1159/Welcome
      3. open the "SThing" link in the background
      4. open the "AThing" link immediately after 3. (<2000ms)
      5. notice neither request returns as the threads are deadlocked

      Show
      1. deploy the attached WELD-1159 .war 2. go to http://127.0.0.1:8080/WELD-1159/Welcome 3. open the "SThing" link in the background 4. open the "AThing" link immediately after 3. (<2000ms) 5. notice neither request returns as the threads are deadlocked

      The following beans will cause a deadlock between Weld AbstractContext session and application contexts creationLock if two requests in the same session are run, where the first one injects "SThing" and the other request injects "AThing".

      The problem is that the first request locks the session scoped lock first and application scoped next, while the other request locks in the opposite order.

      public class ApplicationToSessionProducer
      {
         @Inject
         Instance<AScoped> ascoped;
         
         @Produces
         @SessionScoped
         public SThing getThing() {
            
            try
            {
               Thread.sleep(2000);
            }
            catch (InterruptedException e)
            {
               e.printStackTrace();
            }
            
            ascoped.get().foo();
            
            return new SThing();
         }
      }
      
      public class SessionToApplicationProducer
      {
         @Inject
         Instance<SScoped> sscoped;
         
         @Produces
         @ApplicationScoped
         public AThing getThing() {
            
            sscoped.get().foo();
            
            return new AThing();
         }
      }
      

      where

      @ApplicationScoped
      public class AScoped
      {
         public void foo() {}
      }
      
      @SessionScoped
      public class SScoped implements Serializable
      {
         public void foo() {}
      }
      

        1. jstack.txt
          38 kB
          Marek Schmidt
        2. WELD-1159.tar.gz
          5 kB
          Marek Schmidt
        3. WELD-1159.war
          11 kB
          Marek Schmidt

              ajustin@redhat.com Ales Justin
              maschmid@redhat.com Marek Schmidt
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: