[
https://jira.jboss.org/jira/browse/JBSEAM-3295?page=com.atlassian.jira.pl...
]
Pete Muir resolved JBSEAM-3295.
-------------------------------
Resolution: Done
Assignee: Pete Muir (was: Shane Bryzak)
Denis, I committed a fix that is similar to yours, but it puts the injection inside a sync
block as we need for all components to wait for injection to be complete before
proceeding.
I guess this isn't the most optimized approach, but we will do something better for
beta2.
Can you review for me, and post back if you see some problem?
Thanks
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@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