Upgrade to Coroutines 1.4.0-M1 and use awaitSingle()
This commit raises the minimum Coroutines version supported to 1.4.0-M1 and above, and changes usages of awaitFirst() or awaitFirstOrNull() to awaitSingle() or awaitSingleOrNull() to fix gh-25007. Closes gh-25914 Closes gh-25007
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
package org.springframework.web.reactive.function.client
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.reactive.awaitFirstOrNull
|
||||
import kotlinx.coroutines.reactive.awaitSingleOrNull
|
||||
import kotlinx.coroutines.reactive.awaitSingle
|
||||
import kotlinx.coroutines.reactive.asFlow
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
@@ -115,7 +115,7 @@ suspend fun <T : Any> ClientResponse.awaitBody(clazz: KClass<T>): T =
|
||||
* @since 5.2
|
||||
*/
|
||||
suspend inline fun <reified T : Any> ClientResponse.awaitBodyOrNull(): T? =
|
||||
bodyToMono<T>().awaitFirstOrNull()
|
||||
bodyToMono<T>().awaitSingleOrNull()
|
||||
|
||||
/**
|
||||
* `KClass` nullable coroutines variant of [ClientResponse.bodyToMono].
|
||||
@@ -125,7 +125,7 @@ suspend inline fun <reified T : Any> ClientResponse.awaitBodyOrNull(): T? =
|
||||
* @since 5.3
|
||||
*/
|
||||
suspend fun <T : Any> ClientResponse.awaitBodyOrNull(clazz: KClass<T>): T? =
|
||||
bodyToMono(clazz.java).awaitFirstOrNull()
|
||||
bodyToMono(clazz.java).awaitSingleOrNull()
|
||||
|
||||
/**
|
||||
* Coroutines variant of [ClientResponse.toEntity].
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.web.reactive.function.client
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.reactive.asFlow
|
||||
import kotlinx.coroutines.reactive.awaitFirst
|
||||
import kotlinx.coroutines.reactive.awaitSingle
|
||||
import kotlinx.coroutines.reactive.awaitSingle
|
||||
import kotlinx.coroutines.reactor.asFlux
|
||||
import kotlinx.coroutines.reactor.mono
|
||||
@@ -87,7 +87,7 @@ suspend fun RequestHeadersSpec<out RequestHeadersSpec<*>>.awaitExchange(): Clien
|
||||
* @since 5.3
|
||||
*/
|
||||
suspend fun <T: Any> RequestHeadersSpec<out RequestHeadersSpec<*>>.awaitExchange(responseHandler: suspend (ClientResponse) -> T): T =
|
||||
exchangeToMono { mono(Dispatchers.Unconfined) { responseHandler.invoke(it) } }.awaitFirst()
|
||||
exchangeToMono { mono(Dispatchers.Unconfined) { responseHandler.invoke(it) } }.awaitSingle()
|
||||
|
||||
/**
|
||||
* Coroutines variant of [WebClient.RequestHeadersSpec.exchangeToFlux].
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.web.reactive.function.server
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.reactive.awaitFirst
|
||||
import kotlinx.coroutines.reactive.awaitSingle
|
||||
import kotlinx.coroutines.reactor.mono
|
||||
import org.springframework.core.io.Resource
|
||||
import org.springframework.http.HttpMethod
|
||||
@@ -532,7 +532,7 @@ class CoRouterFunctionDsl internal constructor (private val init: (CoRouterFunct
|
||||
builder.filter { serverRequest, handlerFunction ->
|
||||
mono(Dispatchers.Unconfined) {
|
||||
filterFunction(serverRequest) {
|
||||
handlerFunction.handle(serverRequest).awaitFirst()
|
||||
handlerFunction.handle(serverRequest).awaitSingle()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.web.reactive.function.server
|
||||
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.reactive.awaitFirstOrNull
|
||||
import kotlinx.coroutines.reactive.awaitSingleOrNull
|
||||
import kotlinx.coroutines.reactive.awaitSingle
|
||||
import kotlinx.coroutines.reactive.asFlow
|
||||
import org.springframework.core.ParameterizedTypeReference
|
||||
@@ -99,7 +99,7 @@ suspend fun <T : Any> ServerRequest.awaitBody(clazz: KClass<T>): T =
|
||||
* @since 5.2
|
||||
*/
|
||||
suspend inline fun <reified T : Any> ServerRequest.awaitBodyOrNull(): T? =
|
||||
bodyToMono<T>().awaitFirstOrNull()
|
||||
bodyToMono<T>().awaitSingleOrNull()
|
||||
|
||||
/**
|
||||
* `KClass` nullable Coroutines variant of [ServerRequest.bodyToMono].
|
||||
@@ -109,7 +109,7 @@ suspend inline fun <reified T : Any> ServerRequest.awaitBodyOrNull(): T? =
|
||||
* @since 5.3
|
||||
*/
|
||||
suspend fun <T : Any> ServerRequest.awaitBodyOrNull(clazz: KClass<T>): T? =
|
||||
bodyToMono(clazz.java).awaitFirstOrNull()
|
||||
bodyToMono(clazz.java).awaitSingleOrNull()
|
||||
|
||||
/**
|
||||
* Coroutines variant of [ServerRequest.formData].
|
||||
@@ -136,7 +136,7 @@ suspend fun ServerRequest.awaitMultipartData(): MultiValueMap<String, Part> =
|
||||
* @since 5.2
|
||||
*/
|
||||
suspend fun ServerRequest.awaitPrincipal(): Principal? =
|
||||
principal().awaitFirstOrNull()
|
||||
principal().awaitSingleOrNull()
|
||||
|
||||
/**
|
||||
* Coroutines variant of [ServerRequest.session].
|
||||
|
||||
Reference in New Issue
Block a user