From 090bd4662fd3d525b340333a8e02dfcf09574a7c Mon Sep 17 00:00:00 2001 From: Jakob Edding <15202881+JakobEdding@users.noreply.github.com> Date: Tue, 3 Sep 2024 11:52:43 +0200 Subject: [PATCH] Properly close response body --- src/main/java/com/bakdata/kserve/client/KServeClient.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/bakdata/kserve/client/KServeClient.java b/src/main/java/com/bakdata/kserve/client/KServeClient.java index 0a0f88b..9f932b0 100644 --- a/src/main/java/com/bakdata/kserve/client/KServeClient.java +++ b/src/main/java/com/bakdata/kserve/client/KServeClient.java @@ -100,7 +100,9 @@ private static ObjectMapper createObjectMapper() { } private static String getStringBody(final Response response) throws IOException { - return response.body().string(); + try (ResponseBody body = response.body()) { + return body.string(); + } } private static Optional processJsonResponse(final String stringBody, final Class responseType) {