Support suspending handler methods in Spring MVC

This commit adds support for Kotlin Coroutines suspending functions to
Spring MVC, by converting those to a Mono that can then be handled by
the asynchronous request processing feature.

It also optimizes Coroutines detection with the introduction of an
optimized KotlinDetector.isSuspendingFunction() method that does not
require kotlin-reflect.

Closes gh-23611
This commit is contained in:
Sébastien Deleuze
2020-10-09 12:22:15 +02:00
parent fad7243733
commit 94a42a3086
13 changed files with 110 additions and 29 deletions

View File

@@ -412,8 +412,8 @@ and types like https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-co
Spring Framework provides support for Coroutines on the following scope:
* https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/index.html[Deferred] and https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[Flow] return values support in Spring WebFlux annotated `@Controller`
* Suspending function support in Spring WebFlux annotated `@Controller`
* https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-deferred/index.html[Deferred] and https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html[Flow] return values support in Spring MVC and WebFlux annotated `@Controller`
* Suspending function support in Spring MVC and WebFlux annotated `@Controller`
* Extensions for WebFlux {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.client/index.html[client] and {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/index.html[server] functional API.
* WebFlux.fn {doc-root}/spring-framework/docs/{spring-version}/kdoc-api/spring-framework/org.springframework.web.reactive.function.server/co-router.html[coRouter { }] DSL
* Suspending function and `Flow` support in RSocket `@MessageMapping` annotated methods
@@ -434,7 +434,7 @@ dependencies {
}
----
Version `1.3.0` and above are supported.
Version `1.3.9` and above are supported.
=== How Reactive translates to Coroutines?