Browse Source

Moved executor null check to AsyncExecutionInterceptor, allowing AbstractAsyncExecutionAspect to fall back to sync execution (as in 3.2.1)

Issue: SPR-10636
pull/322/merge
Juergen Hoeller 13 years ago
parent
commit
b6c54c3637
  1. 5
      spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java
  2. 8
      spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java

5
spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionAspectSupport.java

@ -88,7 +88,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
/** /**
* Determine the specific executor to use when executing the given method. * Determine the specific executor to use when executing the given method.
* @return the executor to use (never {@code null}) * @return the executor to use (or {@code null}, but just if no default executor has been set)
*/ */
protected AsyncTaskExecutor determineAsyncExecutor(Method method) { protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
AsyncTaskExecutor executor = this.executors.get(method); AsyncTaskExecutor executor = this.executors.get(method);
@ -102,8 +102,7 @@ public abstract class AsyncExecutionAspectSupport implements BeanFactoryAware {
this.beanFactory, Executor.class, qualifier); this.beanFactory, Executor.class, qualifier);
} }
else if (executorToUse == null) { else if (executorToUse == null) {
throw new IllegalStateException("No executor qualifier specified and no default executor set on " + return null;
getClass().getSimpleName() + " either");
} }
executor = (executorToUse instanceof AsyncTaskExecutor ? executor = (executorToUse instanceof AsyncTaskExecutor ?
(AsyncTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse)); (AsyncTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));

8
spring-aop/src/main/java/org/springframework/aop/interceptor/AsyncExecutionInterceptor.java

@ -83,7 +83,13 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport
Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass); Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass);
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod); specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
Future<?> result = determineAsyncExecutor(specificMethod).submit( AsyncTaskExecutor executor = determineAsyncExecutor(specificMethod);
if (executor == null) {
throw new IllegalStateException(
"No executor specified and no default executor set on AsyncExecutionInterceptor either");
}
Future<?> result = executor.submit(
new Callable<Object>() { new Callable<Object>() {
@Override @Override
public Object call() throws Exception { public Object call() throws Exception {

Loading…
Cancel
Save