BAEL-4970: Close the original response body (#10782)
Co-authored-by: Krzysztof Woyke <krzysztof.woyke.sp@lhsystems.com>
This commit is contained in:
parent
31f40d8623
commit
2553a71828
|
@ -22,6 +22,11 @@ public class ErrorResponseInterceptor implements Interceptor {
|
||||||
String body = gson.toJson(new ErrorMessage(response.code(), "The response from the server was not OK"));
|
String body = gson.toJson(new ErrorMessage(response.code(), "The response from the server was not OK"));
|
||||||
ResponseBody responseBody = ResponseBody.create(body, APPLICATION_JSON);
|
ResponseBody responseBody = ResponseBody.create(body, APPLICATION_JSON);
|
||||||
|
|
||||||
|
ResponseBody originalBody = response.body();
|
||||||
|
if (originalBody != null) {
|
||||||
|
originalBody.close();
|
||||||
|
}
|
||||||
|
|
||||||
return response.newBuilder()
|
return response.newBuilder()
|
||||||
.body(responseBody)
|
.body(responseBody)
|
||||||
.build();
|
.build();
|
||||||
|
|
Loading…
Reference in New Issue