Revisit meaning of response.close() in HTTP client
Prior to this issue, SPR-15920 added this new `close()` method which was supposed to be called to clean resources after response processing. This commit changes the meaning of that method: calling `close()` will close the underlying HTTP connection. This has to be called if the response body is not consumed by the application, since at that point the underlying connection might be in an inconsistent state if shared in a connection pool. Issue: SPR-15993
This commit is contained in:
@@ -43,12 +43,13 @@ public interface ClientHttpResponse extends ReactiveHttpInputMessage, Closeable
|
||||
MultiValueMap<String, ResponseCookie> getCookies();
|
||||
|
||||
/**
|
||||
* Close this response, freeing any resources created.
|
||||
* <p>This non-blocking method has to be called once the response has been
|
||||
* processed and the resources are no longer needed; not doing so might
|
||||
* create resource leaks or connection issues.
|
||||
* <p>Depending on the client configuration and HTTP version,
|
||||
* this can lead to closing the connection or returning it to a connection pool.
|
||||
* Close this response and the underlying HTTP connection.
|
||||
* <p>This non-blocking method has to be called if its body isn't going
|
||||
* to be consumed. Not doing so might result in HTTP connection pool
|
||||
* inconsistencies or memory leaks.
|
||||
* <p>This shouldn't be called if the response body is read,
|
||||
* because it would prevent connections to be reused and cancel
|
||||
* the benefits of using a connection pooling.
|
||||
*/
|
||||
@Override
|
||||
void close();
|
||||
|
||||
Reference in New Issue
Block a user