[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-1918) Asyncronous methods called from an asyncronously executing methoed will not be invoke asyncronously
by Chris Rudd (JIRA)
Asyncronous methods called from an asyncronously executing methoed will not be invoke asyncronously
---------------------------------------------------------------------------------------------------
Key: JBSEAM-1918
URL: http://jira.jboss.com/jira/browse/JBSEAM-1918
Project: JBoss Seam
Issue Type: Bug
Components: Async
Affects Versions: 2.0.0.BETA1
Reporter: Chris Rudd
Currently the AsyncronousInterceptor triggers off of
Contexts.getEventContext().isSet(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL)
to determine if this invocation was from the asyncronous dispatcher. This works fine, except under the conditions where the asyncronously executed method calls another @asyncronous methd. In that case the Event context alreadt contains the AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL marked and the execution is done immedialty instead of being scheduled.
I belive a simple resolution would be to have the AsyncronousInterceptor clear the AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL before proceeding with the exection, but should only be done if the method in question is an @Asycnronous method. This would be to elimiate possible removal from other components that are called during the process of invoking the asyncronous method (ie injection, security, etc).
Here is me proposed change :
AsyncronousInterceptor.java line 24
@AroundInvoke
public Object aroundInvoke(InvocationContext invocation) throws Exception
{
boolean scheduleAsync = invocation.getMethod().isAnnotationPresent(Asynchronous.class) &&
!Contexts.getEventContext().isSet(AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL);
if (scheduleAsync)
{
Dispatcher dispatcher = AbstractDispatcher.instance();
if (dispatcher==null)
{
throw new IllegalStateException("org.jboss.seam.async.dispatcher is not installed in components.xml");
}
Object timer = dispatcher.scheduleInvocation( invocation, getComponent() );
//if the method returns a Timer, return it to the client
return timer!=null && invocation.getMethod().getReturnType().isAssignableFrom( timer.getClass() ) ? timer : null;
}
+ else if( invocation.getMethod().isAnnotationPresent(Asynchronous.class) )
+ {
+ // Clear the async flag so that any async methods called by this invocation will execute asyncronously
+ Contexts.getEventContext().remove( AbstractDispatcher.EXECUTING_ASYNCHRONOUS_CALL );
+ return invocation.proceed();
+ }
else
{
return invocation.proceed();
}
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years, 9 months