[
https://jira.jboss.org/jira/browse/JBSEAM-3295?page=com.atlassian.jira.pl...
]
Denis Forveille reopened JBSEAM-3295:
-------------------------------------
Shane,
the correction you made changes drastically the logic of the Interceptor.
Before, the injection/disinjection was only done on the first method call for a component.
Now you are doing it in for every call, not only the first one. ie when a method of C1
calls another method of C1, you inject/disinject where it was not the case before
This is very different, at least in terms of performance
In your code, the inject/disinject should only be called when reentrantCounter == 0
Also, at a higher level, IMHO, I think that injection/disjection of ressources of an
application scope component should only be done once in the life of the component, not at
every method all
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: Shane Bryzak
Priority: Blocker
Fix For: 2.0.3.CR2, 2.1.0.BETA1
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