Change By: Marek Schmidt (29/Jun/12 7:49 AM)
Description: 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.

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

{code}
public class SessionToApplicationProducer
{
   @Inject
   Instance<SScoped> sscoped;
   
   @Produces
   @ApplicationScoped
   public AThing getThing() {
      
      sscoped.get().foo();
      
      return new AThing();
   }
}
{code}

where

{code}
@ApplicationScoped
public class AScoped
{
   public void foo() {}
}

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

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira