From 946082f8062cf859a30c461ace18ccc6e5dd2872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Mon, 11 Mar 2024 12:17:58 +0100 Subject: [PATCH] Refine publisher type check in CoroutinesUtils See gh-32390 --- .../java/org/springframework/core/CoroutinesUtils.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java b/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java index fa84da293db0..bfb10f7992a4 100644 --- a/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java +++ b/spring-core/src/main/java/org/springframework/core/CoroutinesUtils.java @@ -148,10 +148,10 @@ public static Publisher invokeSuspendingFunction(CoroutineContext context, Me 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;