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
|
@ -21,7 +21,12 @@ public class ErrorResponseInterceptor implements Interceptor {
|
|||
Gson gson = new Gson();
|
||||
String body = gson.toJson(new ErrorMessage(response.code(), "The response from the server was not OK"));
|
||||
ResponseBody responseBody = ResponseBody.create(body, APPLICATION_JSON);
|
||||
|
||||
|
||||
ResponseBody originalBody = response.body();
|
||||
if (originalBody != null) {
|
||||
originalBody.close();
|
||||
}
|
||||
|
||||
return response.newBuilder()
|
||||
.body(responseBody)
|
||||
.build();
|
||||
|
|
Loading…
Reference in New Issue