Skip to content
Permalink
Browse files

Revert "Always close ResponseBody from okHttp"

  • Loading branch information...
antonydenyer committed Jun 4, 2019
1 parent ec2f2e0 commit d7759bb1352d8f28f2621dc8ac819d4bcb83f4d7
Showing with 9 additions and 16 deletions.
  1. +9 −16 core/src/main/java/org/web3j/protocol/http/HttpService.java
@@ -151,24 +151,17 @@ protected InputStream performIO(String request) throws IOException {
okhttp3.Response response = httpClient.newCall(httpRequest).execute();
processHeaders(response.headers());
ResponseBody responseBody = response.body();
try {
if (response.isSuccessful()) {
if (responseBody != null) {
return buildInputStream(responseBody);
} else {
return null;
}
} else {
int code = response.code();
String text = responseBody == null ? "N/A" : responseBody.string();

throw new ClientConnectionException(
"Invalid response received: " + code + "; " + text);
}
} finally {
if (response.isSuccessful()) {
if (responseBody != null) {
responseBody.close();
return buildInputStream(responseBody);
} else {
return null;
}
} else {
int code = response.code();
String text = responseBody == null ? "N/A" : responseBody.string();

throw new ClientConnectionException("Invalid response received: " + code + "; " + text);
}
}

0 comments on commit d7759bb

Please sign in to comment.
You can’t perform that action at this time.