Skip to content

Commit 99bdc42

Browse files
committed
Add Coroutines support to NonReactiveHandlerMethodPredicate
Closes gh-32227
1 parent d47c697 commit 99bdc42

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@
3232
import org.springframework.context.ApplicationContext;
3333
import org.springframework.context.ApplicationContextAware;
3434
import org.springframework.context.ConfigurableApplicationContext;
35+
import org.springframework.core.KotlinDetector;
3536
import org.springframework.core.ReactiveAdapterRegistry;
3637
import org.springframework.http.codec.HttpMessageReader;
3738
import org.springframework.http.codec.ServerCodecConfigurer;
@@ -328,15 +329,17 @@ public Mono<HandlerResult> handleError(ServerWebExchange exchange, Throwable ex)
328329

329330

330331
/**
331-
* Match methods with a return type without an adapter in {@link ReactiveAdapterRegistry}.
332+
* Match methods with a return type without an adapter in {@link ReactiveAdapterRegistry}
333+
* which are not suspending functions.
332334
*/
333335
private record NonReactiveHandlerMethodPredicate(ReactiveAdapterRegistry adapterRegistry)
334336
implements Predicate<HandlerMethod> {
335337

336338
@Override
337339
public boolean test(HandlerMethod handlerMethod) {
338340
Class<?> returnType = handlerMethod.getReturnType().getParameterType();
339-
return (this.adapterRegistry.getAdapter(returnType) == null);
341+
return (this.adapterRegistry.getAdapter(returnType) == null
342+
&& !KotlinDetector.isSuspendingFunction(handlerMethod.getMethod()));
340343
}
341344
}
342345

0 commit comments

Comments
 (0)