[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-3295) Major reentrancy problem with "Application Scope" components and injection/disinjection

Denis Forveille (JIRA) jira-events at lists.jboss.org
Wed Aug 20 17:03:22 EDT 2008

Major reentrancy problem with "Application Scope" components and injection/disinjection

                 Key: JBSEAM-3295
                 URL: https://jira.jboss.org/jira/browse/JBSEAM-3295
             Project: Seam
          Issue Type: Bug
          Components: Core
    Affects Versions: 2.0.2.SP1
         Environment: WebSphere v6.1.0.17 in POJO Mode
            Reporter: Denis Forveille
            Priority: Blocker

There is a major reentrancy problem with "Application Scope" components and injection/disinjection

As in any component @In dependent object are injected/disinjected with  the BijectionInterceptor interceptor

As there is one instance of BijectionInterceptor per Component (It seems), there is only one instance of BijectionInterceptor in the JVM for an Application Scope Component, instance shared by all threads

With that in mind, take:
- 2 running thread (T1, T2)
- One application scope component (C1) with many at In attributes (All referecing Application Scope components too..)

T1 enters method M1 of C1. BijectionInterceptor  inject @In depedencies of C1, and set the "reentrant" attribute of the instance of BijectionInterceptor attached to C1 to  "true"
T2 enters method M1of C1. BijectionInterceptor does nothing as "reentrant"  is true
T1 exits method M1 of C1. As this is thios thread (T1) that set "reentrant" initially, it performs the "disinjection" and set all the @In  attribues of C1 to null
T2 then fails with NPE as all the @In attributes of C1 are set to null !!!!!

Core of the org.jboss.seam.core.BijectionInterceptor class:

   private boolean reentrant; //OK, since all Seam components are single-threaded
   public Object aroundInvoke(InvocationContext invocation) throws Exception{
      if (reentrant) {
         return invocation.proceed();
      else {
         reentrant = true;
         try {
            Component component = getComponent();
            boolean enforceRequired = !component.isLifecycleMethod( invocation.getMethod() );
            component.inject( invocation.getTarget(), enforceRequired );
            Object result = invocation.proceed();            
            component.outject( invocation.getTarget(), enforceRequired );
            component.disinject( invocation.getTarget() );
            return result;
         finally {
            reentrant = false;

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the seam-issues mailing list