Browse Source

Merge branch '6.1.x'

pull/32469/head
Sébastien Deleuze 2 years ago
parent
commit
0435e9c49e
  1. 13
      spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java
  2. 5
      spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java
  3. 5
      spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

13
spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java

@ -33,7 +33,6 @@ import kotlin.reflect.full.KClasses; @@ -33,7 +33,6 @@ import kotlin.reflect.full.KClasses;
import kotlin.reflect.full.KClassifiers;
import kotlin.reflect.full.KTypes;
import kotlin.reflect.jvm.KCallablesJvm;
import kotlin.reflect.jvm.KTypesJvm;
import kotlin.reflect.jvm.ReflectJvmMapping;
import kotlinx.coroutines.BuildersKt;
import kotlinx.coroutines.CoroutineStart;
@ -109,7 +108,7 @@ public abstract class CoroutinesUtils { @@ -109,7 +108,7 @@ public abstract class CoroutinesUtils {
* @throws IllegalArgumentException if {@code method} is not a suspending function
* @since 6.0
*/
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "DataFlowIssue"})
public static Publisher<?> invokeSuspendingFunction(CoroutineContext context, Method method, Object target,
Object... args) {
Assert.isTrue(KotlinDetector.isSuspendingFunction(method), "'method' must be a suspending function");
@ -128,7 +127,7 @@ public abstract class CoroutinesUtils { @@ -128,7 +127,7 @@ public abstract class CoroutinesUtils {
if (!(parameter.isOptional() && arg == null)) {
KType type = parameter.getType();
if (!(type.isMarkedNullable() && arg == null)) {
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
KClass<?> kClass = (KClass<?>) type.getClassifier();
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
}
@ -148,10 +147,10 @@ public abstract class CoroutinesUtils { @@ -148,10 +147,10 @@ public abstract class CoroutinesUtils {
if (KTypes.isSubtypeOf(returnType, flowType)) {
return mono.flatMapMany(CoroutinesUtils::asFlux);
}
else if (KTypes.isSubtypeOf(returnType, monoType)) {
return mono.flatMap(o -> ((Mono<?>)o));
}
else if (KTypes.isSubtypeOf(returnType, publisherType)) {
if (KTypes.isSubtypeOf(returnType, publisherType)) {
if (KTypes.isSubtypeOf(returnType, monoType)) {
return mono.flatMap(o -> ((Mono<?>)o));
}
return mono.flatMapMany(o -> ((Publisher<?>)o));
}
return mono;

5
spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java

@ -29,7 +29,6 @@ import kotlin.reflect.KParameter; @@ -29,7 +29,6 @@ import kotlin.reflect.KParameter;
import kotlin.reflect.KType;
import kotlin.reflect.full.KClasses;
import kotlin.reflect.jvm.KCallablesJvm;
import kotlin.reflect.jvm.KTypesJvm;
import kotlin.reflect.jvm.ReflectJvmMapping;
import org.springframework.context.MessageSource;
@ -299,7 +298,7 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -299,7 +298,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
private static class KotlinDelegate {
@Nullable
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "DataFlowIssue"})
public static Object invokeFunction(Method method, Object target, Object[] args) throws InvocationTargetException, IllegalAccessException {
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
// For property accessors
@ -319,7 +318,7 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -319,7 +318,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
if (!(parameter.isOptional() && arg == null)) {
KType type = parameter.getType();
if (!(type.isMarkedNullable() && arg == null)) {
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
KClass<?> kClass = (KClass<?>) type.getClassifier();
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
}

5
spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

@ -34,7 +34,6 @@ import kotlin.reflect.KParameter; @@ -34,7 +34,6 @@ import kotlin.reflect.KParameter;
import kotlin.reflect.KType;
import kotlin.reflect.full.KClasses;
import kotlin.reflect.jvm.KCallablesJvm;
import kotlin.reflect.jvm.KTypesJvm;
import kotlin.reflect.jvm.ReflectJvmMapping;
import reactor.core.publisher.Mono;
@ -298,7 +297,7 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -298,7 +297,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
private static final String COROUTINE_CONTEXT_ATTRIBUTE = "org.springframework.web.server.CoWebFilter.context";
@Nullable
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "DataFlowIssue"})
public static Object invokeFunction(Method method, Object target, Object[] args, boolean isSuspendingFunction,
ServerWebExchange exchange) throws InvocationTargetException, IllegalAccessException {
@ -330,7 +329,7 @@ public class InvocableHandlerMethod extends HandlerMethod { @@ -330,7 +329,7 @@ public class InvocableHandlerMethod extends HandlerMethod {
if (!(parameter.isOptional() && arg == null)) {
KType type = parameter.getType();
if (!(type.isMarkedNullable() && arg == null)) {
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
KClass<?> kClass = (KClass<?>) type.getClassifier();
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
}

Loading…
Cancel
Save