Merge branch '6.1.x'
This commit is contained in:
@@ -19,15 +19,9 @@ package org.springframework.cache.interceptor;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import kotlin.coroutines.Continuation;
|
||||
import kotlin.coroutines.CoroutineContext;
|
||||
import kotlinx.coroutines.Job;
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.core.CoroutinesUtils;
|
||||
import org.springframework.core.KotlinDetector;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -58,9 +52,6 @@ public class CacheInterceptor extends CacheAspectSupport implements MethodInterc
|
||||
|
||||
CacheOperationInvoker aopAllianceInvoker = () -> {
|
||||
try {
|
||||
if (KotlinDetector.isKotlinReflectPresent() && KotlinDetector.isSuspendingFunction(method)) {
|
||||
return KotlinDelegate.invokeSuspendingFunction(method, invocation.getThis(), invocation.getArguments());
|
||||
}
|
||||
return invocation.proceed();
|
||||
}
|
||||
catch (Throwable ex) {
|
||||
@@ -78,17 +69,4 @@ public class CacheInterceptor extends CacheAspectSupport implements MethodInterc
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Inner class to avoid a hard dependency on Kotlin at runtime.
|
||||
*/
|
||||
private static class KotlinDelegate {
|
||||
|
||||
public static Publisher<?> invokeSuspendingFunction(Method method, @Nullable Object target, Object... args) {
|
||||
Continuation<?> continuation = (Continuation<?>) args[args.length - 1];
|
||||
CoroutineContext coroutineContext = continuation.getContext().minusKey(Job.Key);
|
||||
return CoroutinesUtils.invokeSuspendingFunction(coroutineContext, method, target, args);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user