From 7e9c33f50e25896531a063039dd96e532b3bb8f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Wed, 26 Mar 2025 10:56:34 +0100 Subject: [PATCH] Polishing See gh-34555 --- .../function/client/WebClientExtensions.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) 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