diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt index dd8449969c..033bc3a3ce 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/client/WebClientExtensions.kt @@ -91,7 +91,9 @@ inline fun RequestBodySpec.bodyValueWithType(body: T): Request */ suspend fun RequestHeadersSpec>.awaitExchange(responseHandler: suspend (ClientResponse) -> T): T { val context = currentCoroutineContext().minusKey(Job.Key) - return withContext(context.toReactorContext()) { exchangeToMono { mono(context) { responseHandler.invoke(it) } }.awaitSingle() } + return withContext(context.toReactorContext()) { + exchangeToMono { mono(context) { responseHandler.invoke(it) } }.awaitSingle() + } } /** @@ -101,7 +103,9 @@ suspend fun RequestHeadersSpec>.awaitExchange */ suspend fun RequestHeadersSpec>.awaitExchangeOrNull(responseHandler: suspend (ClientResponse) -> T?): T? { val context = currentCoroutineContext().minusKey(Job.Key) - return withContext(context.toReactorContext()) { exchangeToMono { mono(context) { responseHandler.invoke(it) } }.awaitSingleOrNull() } + return withContext(context.toReactorContext()) { + exchangeToMono { mono(context) { responseHandler.invoke(it) } }.awaitSingleOrNull() + } } /** @@ -183,7 +187,9 @@ suspend inline fun WebClient.ResponseSpec.awaitBodyOrNull() : */ suspend fun WebClient.ResponseSpec.awaitBodilessEntity(): ResponseEntity { val context = currentCoroutineContext().minusKey(Job.Key) - return withContext(context.toReactorContext()) { toBodilessEntity().awaitSingle() } + return withContext(context.toReactorContext()) { + toBodilessEntity().awaitSingle() + } } /** @@ -222,11 +228,13 @@ inline fun WebClient.ResponseSpec.toEntityFlux(): Mono WebClient.ResponseSpec.awaitEntity(): ResponseEntity { val context = currentCoroutineContext().minusKey(Job.Key) - return withContext(context.toReactorContext()) { toEntity(T::class.java).awaitSingle() } + return withContext(context.toReactorContext()) { + toEntity(T::class.java).awaitSingle() + } } @PublishedApi