Skip to content

Commit b242217

Browse files
committed
ReactorNettyClientResponse should close response body
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
1 parent 7a666cf commit b242217

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

spring-web/src/main/java/org/springframework/http/client/ReactorNettyClientResponse.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.springframework.http.HttpStatusCode;
2828
import org.springframework.http.support.Netty4HeadersAdapter;
2929
import org.springframework.lang.Nullable;
30+
import org.springframework.util.StreamUtils;
3031

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

9091
@Override
9192
public void close() {
92-
this.connection.dispose();
93+
try{
94+
InputStream body = getBody();
95+
StreamUtils.drain(body);
96+
body.close();
97+
}
98+
catch (IOException ignored) {
99+
}
93100
}
94101

95102
}

0 commit comments

Comments
 (0)