Skip to content

Commit 8e21023

Browse files
committed
Update docs on ClientResponse
Issue: SPR-16200
1 parent 19a9bc4 commit 8e21023

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/ClientResponse.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,14 @@
3838
* {@link ExchangeFunction}. Provides access to the response status and headers,
3939
* and also methods to consume the response body.
4040
*
41-
* <p><strong>NOTE:</strong> When given access to a {@link ClientResponse} you
42-
* must always use the response body or entity methods to ensure resources are
43-
* released and to avoid potential issues with HTTP connection pooling. If not
44-
* interested in the response body, use {@code "bodyToMono(Void.class)"}.
41+
* <p><strong>NOTE:</strong> When given access to a {@link ClientResponse},
42+
* through the {@code WebClient}
43+
* {@link WebClient.RequestHeadersSpec#exchange() exchange()} method,
44+
* you must always use one of the body or toEntity methods to ensure resources
45+
* are released and avoid potential issues with HTTP connection pooling.
46+
* You can use {@code bodyToMono(Void.class)} if no response content is
47+
* expected. However keep in mind that if the response does have content, the
48+
* connection will be closed and will not be placed back in the pool.
4549
*
4650
* @author Brian Clozel
4751
* @author Arjen Poutsma

spring-webflux/src/main/java/org/springframework/web/reactive/function/client/WebClient.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,9 @@ interface RequestHeadersSpec<S extends RequestHeadersSpec<S>> {
483483
* .exchange()
484484
* .flatMapMany(response -> response.bodyToFlux(Person.class));
485485
* </pre>
486-
* <p><strong>NOTE:</strong> You must always use of the body or entity
487-
* methods on {@link ClientResponse} to ensure resources are released and
488-
* avoid potential issues with HTTP connection pooling. If not interested
489-
* in the response body, use {@code "bodyToMono(Void.class)"} to complete.
486+
* <p><strong>NOTE:</strong> You must always use one of the body or
487+
* entity methods of the response to ensure resources are released.
488+
* See {@link ClientResponse} for more details.
490489
* @return a {@code Mono} for the response
491490
* @see #retrieve()
492491
*/

src/docs/asciidoc/web/webflux-webclient.adoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ Note that unlike `retrieve()`, with `exchange()` there are no automatic error si
9999

100100
[CAUTION]
101101
====
102-
When using `exchange()` you must always use any of the body or entity methods of
102+
When using `exchange()` you must always use any of the body or toEntity methods of
103103
`ClientResponse` to ensure resources are released and to avoid potential issues with HTTP
104-
connection pooling. If not interested in the response body use `bodyToMono(Void.class)`
105-
to complete.
104+
connection pooling. You can use `bodyToMono(Void.class)` if no response content is
105+
expected. However keep in mind that if the response does have content, the connection
106+
will be closed and will not be placed back in the pool.
106107
====
107108

108109

0 commit comments

Comments
 (0)