|
|
|
|
@ -28,7 +28,6 @@ import java.util.Set;
@@ -28,7 +28,6 @@ import java.util.Set;
|
|
|
|
|
import kotlin.coroutines.Continuation; |
|
|
|
|
import kotlin.coroutines.CoroutineContext; |
|
|
|
|
import kotlinx.coroutines.Job; |
|
|
|
|
import org.reactivestreams.Publisher; |
|
|
|
|
|
|
|
|
|
import org.springframework.aop.Advisor; |
|
|
|
|
import org.springframework.aop.AopInvocationException; |
|
|
|
|
@ -65,6 +64,9 @@ import org.springframework.util.ReflectionUtils;
@@ -65,6 +64,9 @@ import org.springframework.util.ReflectionUtils;
|
|
|
|
|
*/ |
|
|
|
|
public abstract class AopUtils { |
|
|
|
|
|
|
|
|
|
private static final boolean coroutinesReactorPresent = ClassUtils.isPresent("kotlinx.coroutines.reactor.MonoKt", |
|
|
|
|
AopUtils.class.getClassLoader());; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Check whether the given object is a JDK dynamic proxy or a CGLIB proxy. |
|
|
|
|
* <p>This method additionally checks if the given object is an instance |
|
|
|
|
@ -347,7 +349,7 @@ public abstract class AopUtils {
@@ -347,7 +349,7 @@ public abstract class AopUtils {
|
|
|
|
|
// Use reflection to invoke the method.
|
|
|
|
|
try { |
|
|
|
|
ReflectionUtils.makeAccessible(method); |
|
|
|
|
return KotlinDetector.isSuspendingFunction(method) ? |
|
|
|
|
return coroutinesReactorPresent && KotlinDetector.isSuspendingFunction(method) ? |
|
|
|
|
KotlinDelegate.invokeSuspendingFunction(method, target, args) : method.invoke(target, args); |
|
|
|
|
} |
|
|
|
|
catch (InvocationTargetException ex) { |
|
|
|
|
@ -370,7 +372,7 @@ public abstract class AopUtils {
@@ -370,7 +372,7 @@ public abstract class AopUtils {
|
|
|
|
|
*/ |
|
|
|
|
private static class KotlinDelegate { |
|
|
|
|
|
|
|
|
|
public static Publisher<?> invokeSuspendingFunction(Method method, @Nullable Object target, Object... args) { |
|
|
|
|
public static Object invokeSuspendingFunction(Method method, @Nullable Object target, Object... args) { |
|
|
|
|
Continuation<?> continuation = (Continuation<?>) args[args.length -1]; |
|
|
|
|
Assert.state(continuation != null, "No Continuation available"); |
|
|
|
|
CoroutineContext context = continuation.getContext().minusKey(Job.Key); |
|
|
|
|
|