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

Pete Muir (JIRA) jira-events at lists.jboss.org
Fri Aug 22 17:25:40 EDT 2008

    [ https://jira.jboss.org/jira/browse/JBSEAM-3295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12426293#action_12426293 ] 

Pete Muir commented on JBSEAM-3295:


1) Yes, we will work on an optimized version for the branch and trunk - JBSEAM-3301 covers this. Main concern right now is releasing 2.1 beta1 ;-)

2) Correct, you *don't* want to outject if the invocation of the business method throws an exception but you do want to disinject - as ever, with exception processing, you want to halt when the exception is thrown, and do cleanup (disinjection).

Thanks for the help with this :-)

> 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
>            Assignee: Pete Muir
>            Priority: Blocker
>             Fix For: 2.0.3.CR2, 2.1.0.BETA1
>         Attachments: BijectionInterceptor_Denis.java
> 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
>    @AroundInvoke
>    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