Skip to content

Commit 0444e23

Browse files
jfuerthadriancole
authored andcommitted
Don't leak OkHttp response when response.body() is null (OpenFeign#556)
Signed-off-by: Jonathan Fuerth <jonathan@helpful.com>
1 parent 30ff85f commit 0444e23

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

okhttp/src/main/java/feign/okhttp/OkHttpClient.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.io.IOException;
2626
import java.io.InputStream;
2727
import java.io.Reader;
28-
import java.util.Arrays;
2928
import java.util.Collection;
3029
import java.util.Map;
3130
import java.util.concurrent.TimeUnit;
@@ -106,6 +105,9 @@ private static Map<String, Collection<String>> toMap(Headers headers) {
106105

107106
private static feign.Response.Body toBody(final ResponseBody input) throws IOException {
108107
if (input == null || input.contentLength() == 0) {
108+
if (input != null) {
109+
input.close();
110+
}
109111
return null;
110112
}
111113
final Integer length = input.contentLength() >= 0 && input.contentLength() <= Integer.MAX_VALUE ?

0 commit comments

Comments
 (0)