28
28
import kotlin .coroutines .Continuation ;
29
29
import kotlin .coroutines .CoroutineContext ;
30
30
import kotlinx .coroutines .Job ;
31
- import org .reactivestreams .Publisher ;
32
31
33
32
import org .springframework .aop .Advisor ;
34
33
import org .springframework .aop .AopInvocationException ;
65
64
*/
66
65
public abstract class AopUtils {
67
66
67
+ private static final boolean coroutinesReactorPresent = ClassUtils .isPresent ("kotlinx.coroutines.reactor.MonoKt" ,
68
+ AopUtils .class .getClassLoader ());;
69
+
68
70
/**
69
71
* Check whether the given object is a JDK dynamic proxy or a CGLIB proxy.
70
72
* <p>This method additionally checks if the given object is an instance
@@ -347,7 +349,7 @@ public static Object invokeJoinpointUsingReflection(@Nullable Object target, Met
347
349
// Use reflection to invoke the method.
348
350
try {
349
351
ReflectionUtils .makeAccessible (method );
350
- return KotlinDetector .isSuspendingFunction (method ) ?
352
+ return coroutinesReactorPresent && KotlinDetector .isSuspendingFunction (method ) ?
351
353
KotlinDelegate .invokeSuspendingFunction (method , target , args ) : method .invoke (target , args );
352
354
}
353
355
catch (InvocationTargetException ex ) {
@@ -370,7 +372,7 @@ public static Object invokeJoinpointUsingReflection(@Nullable Object target, Met
370
372
*/
371
373
private static class KotlinDelegate {
372
374
373
- public static Publisher <?> invokeSuspendingFunction (Method method , @ Nullable Object target , Object ... args ) {
375
+ public static Object invokeSuspendingFunction (Method method , @ Nullable Object target , Object ... args ) {
374
376
Continuation <?> continuation = (Continuation <?>) args [args .length -1 ];
375
377
Assert .state (continuation != null , "No Continuation available" );
376
378
CoroutineContext context = continuation .getContext ().minusKey (Job .Key );
0 commit comments