Skip to content

Commit

Permalink
Add try-with-resources
Browse files Browse the repository at this point in the history
  • Loading branch information
rpoet-jh committed Apr 29, 2024
1 parent 2c11ca7 commit 0e6fac2
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -681,11 +681,14 @@ public void deleteFile(File file) throws IOException {
.addEncodedPathSegments(file.getUri().getRawPath().substring(1)).build();

Request requestFileBin = new Request.Builder().url(urlFileBin).delete().build();
Response responseFileBin = client.newCall(requestFileBin).execute();

if (!responseFileBin.isSuccessful() && responseFileBin.code() != 404) {
throw new IOException(String.format("Failed to delete for File: %s, URL: %s, Status code: %d",
file.getId(), urlFileBin, responseFileBin.code()));
try (Response responseFileBin = client.newCall(requestFileBin).execute()) {
if (responseFileBin.code() == 404) {
return;
}
if (!responseFileBin.isSuccessful()) {
throw new IOException(String.format("Failed to delete for File: %s, URL: %s, Status code: %d",
file.getId(), urlFileBin, responseFileBin.code()));
}
}

deleteObject(file);
Expand Down

0 comments on commit 0e6fac2

Please sign in to comment.