diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java index 07833effee..2e24eb080c 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java @@ -38,10 +38,14 @@ import org.springframework.web.reactive.function.BodyExtractor; * {@link ExchangeFunction}. Provides access to the response status and headers, * and also methods to consume the response body. * - *

NOTE: When given access to a {@link ClientResponse} you - * must always use the response body or entity methods to ensure resources are - * released and to avoid potential issues with HTTP connection pooling. If not - * interested in the response body, use {@code "bodyToMono(Void.class)"}. + *

NOTE: When given access to a {@link ClientResponse}, + * through the {@code WebClient} + * {@link WebClient.RequestHeadersSpec#exchange() exchange()} method, + * you must always use one of the body or toEntity methods to ensure resources + * are released and avoid potential issues with HTTP connection pooling. + * You can use {@code bodyToMono(Void.class)} if no response content is + * expected. However keep in mind that if the response does have content, the + * connection will be closed and will not be placed back in the pool. * * @author Brian Clozel * @author Arjen Poutsma diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java index 0033522461..161f699d1a 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java @@ -483,10 +483,9 @@ public interface WebClient { * .exchange() * .flatMapMany(response -> response.bodyToFlux(Person.class)); * - *

NOTE: You must always use of the body or entity - * methods on {@link ClientResponse} to ensure resources are released and - * avoid potential issues with HTTP connection pooling. If not interested - * in the response body, use {@code "bodyToMono(Void.class)"} to complete. + *

NOTE: You must always use one of the body or + * entity methods of the response to ensure resources are released. + * See {@link ClientResponse} for more details. * @return a {@code Mono} for the response * @see #retrieve() */ diff --git a/src/docs/asciidoc/web/webflux-webclient.adoc b/src/docs/asciidoc/web/webflux-webclient.adoc index 879da9f3aa..31edbba93f 100644 --- a/src/docs/asciidoc/web/webflux-webclient.adoc +++ b/src/docs/asciidoc/web/webflux-webclient.adoc @@ -99,10 +99,11 @@ Note that unlike `retrieve()`, with `exchange()` there are no automatic error si [CAUTION] ==== -When using `exchange()` you must always use any of the body or entity methods of +When using `exchange()` you must always use any of the body or toEntity methods of `ClientResponse` to ensure resources are released and to avoid potential issues with HTTP -connection pooling. If not interested in the response body use `bodyToMono(Void.class)` -to complete. +connection pooling. You can use `bodyToMono(Void.class)` if no response content is +expected. However keep in mind that if the response does have content, the connection +will be closed and will not be placed back in the pool. ====