Issue Type: Bug Bug
Affects Versions: 1.1.8.Final, 2.0.0.Alpha2
Assignee: Ales Justin
Attachments: jstack.txt, WELD-1159.tar.gz, WELD-1159.war
Components: Scopes & Contexts
Created: 10/Jul/12 10:11 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.

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() {}
}
Environment: JBoss AS 7.1.2.Final
Project: Weld
Priority: Major Major
Reporter: Marek Schmidt
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