Skip to content

Commit 946082f

Browse files
committed
Refine publisher type check in CoroutinesUtils
See gh-32390
1 parent 78fb378 commit 946082f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ public static Publisher<?> invokeSuspendingFunction(CoroutineContext context, Me
148148
if (KTypes.isSubtypeOf(returnType, flowType)) {
149149
return mono.flatMapMany(CoroutinesUtils::asFlux);
150150
}
151-
else if (KTypes.isSubtypeOf(returnType, monoType)) {
152-
return mono.flatMap(o -> ((Mono<?>)o));
153-
}
154-
else if (KTypes.isSubtypeOf(returnType, publisherType)) {
151+
if (KTypes.isSubtypeOf(returnType, publisherType)) {
152+
if (KTypes.isSubtypeOf(returnType, monoType)) {
153+
return mono.flatMap(o -> ((Mono<?>)o));
154+
}
155155
return mono.flatMapMany(o -> ((Publisher<?>)o));
156156
}
157157
return mono;

0 commit comments

Comments
 (0)