Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly close response body #15

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
`java-library`
id("com.bakdata.release") version "1.4.0"
id("com.bakdata.sonar") version "1.4.0"
id("com.bakdata.sonatype") version "1.4.0"
id("com.bakdata.sonatype") version "1.4.1"
id("io.freefair.lombok") version "8.4"
id("java-test-fixtures")
}
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/bakdata/kserve/client/KServeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import okhttp3.ResponseBody;
import org.jetbrains.annotations.NotNull;

/**
Expand Down Expand Up @@ -100,7 +101,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 <T> Optional<T> processJsonResponse(final String stringBody, final Class<? extends T> responseType) {
Expand Down
Loading