Skip to content

Commit 0435e9c

Browse files
committed
Merge branch '6.1.x'
2 parents 38c831f + 80f3be6 commit 0435e9c

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import kotlin.reflect.full.KClassifiers;
3434
import kotlin.reflect.full.KTypes;
3535
import kotlin.reflect.jvm.KCallablesJvm;
36-
import kotlin.reflect.jvm.KTypesJvm;
3736
import kotlin.reflect.jvm.ReflectJvmMapping;
3837
import kotlinx.coroutines.BuildersKt;
3938
import kotlinx.coroutines.CoroutineStart;
@@ -109,7 +108,7 @@ public static Publisher<?> invokeSuspendingFunction(Method method, Object target
109108
* @throws IllegalArgumentException if {@code method} is not a suspending function
110109
* @since 6.0
111110
*/
112-
@SuppressWarnings("deprecation")
111+
@SuppressWarnings({"deprecation", "DataFlowIssue"})
113112
public static Publisher<?> invokeSuspendingFunction(CoroutineContext context, Method method, Object target,
114113
Object... args) {
115114
Assert.isTrue(KotlinDetector.isSuspendingFunction(method), "'method' must be a suspending function");
@@ -128,7 +127,7 @@ public static Publisher<?> invokeSuspendingFunction(CoroutineContext context, Me
128127
if (!(parameter.isOptional() && arg == null)) {
129128
KType type = parameter.getType();
130129
if (!(type.isMarkedNullable() && arg == null)) {
131-
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
130+
KClass<?> kClass = (KClass<?>) type.getClassifier();
132131
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
133132
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
134133
}
@@ -148,10 +147,10 @@ public static Publisher<?> invokeSuspendingFunction(CoroutineContext context, Me
148147
if (KTypes.isSubtypeOf(returnType, flowType)) {
149148
return mono.flatMapMany(CoroutinesUtils::asFlux);
150149
}
151-
else if (KTypes.isSubtypeOf(returnType, monoType)) {
152-
return mono.flatMap(o -> ((Mono<?>)o));
153-
}
154-
else if (KTypes.isSubtypeOf(returnType, publisherType)) {
150+
if (KTypes.isSubtypeOf(returnType, publisherType)) {
151+
if (KTypes.isSubtypeOf(returnType, monoType)) {
152+
return mono.flatMap(o -> ((Mono<?>)o));
153+
}
155154
return mono.flatMapMany(o -> ((Publisher<?>)o));
156155
}
157156
return mono;

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import kotlin.reflect.KType;
3030
import kotlin.reflect.full.KClasses;
3131
import kotlin.reflect.jvm.KCallablesJvm;
32-
import kotlin.reflect.jvm.KTypesJvm;
3332
import kotlin.reflect.jvm.ReflectJvmMapping;
3433

3534
import org.springframework.context.MessageSource;
@@ -299,7 +298,7 @@ protected Object invokeSuspendingFunction(Method method, Object target, Object[]
299298
private static class KotlinDelegate {
300299

301300
@Nullable
302-
@SuppressWarnings("deprecation")
301+
@SuppressWarnings({"deprecation", "DataFlowIssue"})
303302
public static Object invokeFunction(Method method, Object target, Object[] args) throws InvocationTargetException, IllegalAccessException {
304303
KFunction<?> function = ReflectJvmMapping.getKotlinFunction(method);
305304
// For property accessors
@@ -319,7 +318,7 @@ public static Object invokeFunction(Method method, Object target, Object[] args)
319318
if (!(parameter.isOptional() && arg == null)) {
320319
KType type = parameter.getType();
321320
if (!(type.isMarkedNullable() && arg == null)) {
322-
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
321+
KClass<?> kClass = (KClass<?>) type.getClassifier();
323322
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
324323
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
325324
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import kotlin.reflect.KType;
3535
import kotlin.reflect.full.KClasses;
3636
import kotlin.reflect.jvm.KCallablesJvm;
37-
import kotlin.reflect.jvm.KTypesJvm;
3837
import kotlin.reflect.jvm.ReflectJvmMapping;
3938
import reactor.core.publisher.Mono;
4039

@@ -298,7 +297,7 @@ private static class KotlinDelegate {
298297
private static final String COROUTINE_CONTEXT_ATTRIBUTE = "org.springframework.web.server.CoWebFilter.context";
299298

300299
@Nullable
301-
@SuppressWarnings("deprecation")
300+
@SuppressWarnings({"deprecation", "DataFlowIssue"})
302301
public static Object invokeFunction(Method method, Object target, Object[] args, boolean isSuspendingFunction,
303302
ServerWebExchange exchange) throws InvocationTargetException, IllegalAccessException {
304303

@@ -330,7 +329,7 @@ public static Object invokeFunction(Method method, Object target, Object[] args,
330329
if (!(parameter.isOptional() && arg == null)) {
331330
KType type = parameter.getType();
332331
if (!(type.isMarkedNullable() && arg == null)) {
333-
KClass<?> kClass = KTypesJvm.getJvmErasure(type);
332+
KClass<?> kClass = (KClass<?>) type.getClassifier();
334333
if (KotlinDetector.isInlineClass(JvmClassMappingKt.getJavaClass(kClass))) {
335334
arg = KClasses.getPrimaryConstructor(kClass).call(arg);
336335
}

0 commit comments

Comments
 (0)