Use proper return type in AsyncExecutionInterceptor

See gh-33957
This commit is contained in:
Bao.Ngo
2025-02-04 15:58:53 +01:00
committed by Stéphane Nicoll
parent cda7e98643
commit 8eb24458f8
2 changed files with 86 additions and 1 deletions
@@ -17,6 +17,7 @@
package org.springframework.aop.interceptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
@@ -60,6 +61,7 @@ import org.springframework.lang.Nullable;
* @author Juergen Hoeller
* @author Chris Beams
* @author Stephane Nicoll
* @author Bao Ngo
* @since 3.0
* @see org.springframework.scheduling.annotation.Async
* @see org.springframework.scheduling.annotation.AsyncAnnotationAdvisor
@@ -125,7 +127,16 @@ public class AsyncExecutionInterceptor extends AsyncExecutionAspectSupport imple
return null;
};
return doSubmit(task, executor, invocation.getMethod().getReturnType());
return doSubmit( task, executor, determineReturnType( invocation, userMethod ) );
}
private static Class<?> determineReturnType(MethodInvocation invocation, Method userMethod) {
Method originalMethod = invocation.getMethod();
if( Modifier.isAbstract( originalMethod.getModifiers() ) ) {
return userMethod.getReturnType();
}
return originalMethod.getReturnType();
}
/**