Ensure response body is closed when a http request is not successful (#1912)

This commit is contained in:
Luck 2020-01-10 12:50:40 +00:00
parent b73b73e221
commit 352f3bd263
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -46,6 +46,7 @@ public class AbstractHttpClient {
protected Response makeHttpRequest(Request request) throws IOException {
Response response = this.okHttp.newCall(request).execute();
if (!response.isSuccessful()) {
response.close();
throw new RuntimeException("Request was unsuccessful: " + response.code() + " - " + response.message());
}
return response;