File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 16
16
17
17
package org.springframework.web.reactive.function.client
18
18
19
+ import kotlinx.coroutines.Job
20
+ import kotlinx.coroutines.currentCoroutineContext
19
21
import kotlinx.coroutines.Dispatchers
20
22
import kotlinx.coroutines.flow.Flow
21
23
import kotlinx.coroutines.reactive.asFlow
@@ -87,16 +89,20 @@ suspend fun RequestHeadersSpec<out RequestHeadersSpec<*>>.awaitExchange(): Clien
87
89
* @author Sebastien Deleuze
88
90
* @since 5.3
89
91
*/
90
- suspend fun <T : Any > RequestHeadersSpec <out RequestHeadersSpec <* >>.awaitExchange (responseHandler : suspend (ClientResponse ) -> T ): T =
91
- exchangeToMono { mono(Dispatchers .Unconfined ) { responseHandler.invoke(it) } }.awaitSingle()
92
+ suspend fun <T : Any > RequestHeadersSpec <out RequestHeadersSpec <* >>.awaitExchange (responseHandler : suspend (ClientResponse ) -> T ): T {
93
+ val context = currentCoroutineContext().minusKey(Job .Key )
94
+ return exchangeToMono { mono(context) { responseHandler.invoke(it) } }.awaitSingle()
95
+ }
92
96
93
97
/* *
94
98
* Variant of [WebClient.RequestHeadersSpec.awaitExchange] that allows a nullable return
95
99
*
96
100
* @since 5.3.8
97
101
*/
98
- suspend fun <T : Any > RequestHeadersSpec <out RequestHeadersSpec <* >>.awaitExchangeOrNull (responseHandler : suspend (ClientResponse ) -> T ? ): T ? =
99
- exchangeToMono { mono(Dispatchers .Unconfined ) { responseHandler.invoke(it) } }.awaitSingleOrNull()
102
+ suspend fun <T : Any > RequestHeadersSpec <out RequestHeadersSpec <* >>.awaitExchangeOrNull (responseHandler : suspend (ClientResponse ) -> T ? ): T ? {
103
+ val context = currentCoroutineContext().minusKey(Job .Key )
104
+ return exchangeToMono { mono(context) { responseHandler.invoke(it) } }.awaitSingleOrNull()
105
+ }
100
106
101
107
/* *
102
108
* Coroutines variant of [WebClient.RequestHeadersSpec.exchangeToFlux].
You can’t perform that action at this time.
0 commit comments