Skip to content

Commit

Permalink
ReactorNettyClientResponse should close response body
Browse files Browse the repository at this point in the history
This commit ensures that the response body is drained and closed when
the response itself is closed, instead of disposing the connection, as
this will disable the connection pool.

Closes gh-32528
  • Loading branch information
poutsma committed Apr 5, 2024
1 parent 7a666cf commit b242217
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.http.HttpStatusCode;
import org.springframework.http.support.Netty4HeadersAdapter;
import org.springframework.lang.Nullable;
import org.springframework.util.StreamUtils;

/**
* {@link ClientHttpResponse} implementation for the Reactor-Netty HTTP client.
Expand Down Expand Up @@ -89,7 +90,13 @@ public InputStream getBody() throws IOException {

@Override
public void close() {
this.connection.dispose();
try{
InputStream body = getBody();
StreamUtils.drain(body);
body.close();
}
catch (IOException ignored) {
}
}

}

0 comments on commit b242217

Please sign in to comment.