Skip to content

Commit b6c54c3

Browse files
committed
Moved executor null check to AsyncExecutionInterceptor, allowing AbstractAsyncExecutionAspect to fall back to sync execution (as in 3.2.1)
Issue: SPR-10636
1 parent 2e4eb9f commit b6c54c3

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
8888

8989
/**
9090
* Determine the specific executor to use when executing the given method.
91-
* @return the executor to use (never {@code null})
91+
* @return the executor to use (or {@code null}, but just if no default executor has been set)
9292
*/
9393
protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
9494
AsyncTaskExecutor executor = this.executors.get(method);
@@ -102,8 +102,7 @@ protected AsyncTaskExecutor determineAsyncExecutor(Method method) {
102102
this.beanFactory, Executor.class, qualifier);
103103
}
104104
else if (executorToUse == null) {
105-
throw new IllegalStateException("No executor qualifier specified and no default executor set on " +
106-
getClass().getSimpleName() + " either");
105+
return null;
107106
}
108107
executor = (executorToUse instanceof AsyncTaskExecutor ?
109108
(AsyncTaskExecutor) executorToUse : new TaskExecutorAdapter(executorToUse));

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,13 @@ public Object invoke(final MethodInvocation invocation) throws Throwable {
8383
Method specificMethod = ClassUtils.getMostSpecificMethod(invocation.getMethod(), targetClass);
8484
specificMethod = BridgeMethodResolver.findBridgedMethod(specificMethod);
8585

86-
Future<?> result = determineAsyncExecutor(specificMethod).submit(
86+
AsyncTaskExecutor executor = determineAsyncExecutor(specificMethod);
87+
if (executor == null) {
88+
throw new IllegalStateException(
89+
"No executor specified and no default executor set on AsyncExecutionInterceptor either");
90+
}
91+
92+
Future<?> result = executor.submit(
8793
new Callable<Object>() {
8894
@Override
8995
public Object call() throws Exception {

0 commit comments

Comments
 (0)