Skip to content

Commit

Permalink
* fix not thrown exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pa.sharaev committed Jan 18, 2024
1 parent 765caf4 commit d5c11e4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/main/java/org/twonote/rgwadmin4j/impl/RgwAdminImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,25 @@ public Optional<BucketInfo> getBucketInfo(String bucketName) {
throw new RuntimeException("Server should not return more than one bucket");
}

private String call(Request request) {
try (Response response = client.newCall(request).execute()) {
if (response.code() == 404) {
throw new RgwAdminException(404, "not found");
}
if (!response.isSuccessful()) {
throw ErrorUtils.parseError(response);
}
ResponseBody body = response.body();
if (body != null) {
return response.body().string();
} else {
return null;
}
} catch (IOException e) {
throw new RgwAdminException(500, "IOException", e);
}
}

/**
* Guarantee that the request is execute success and the connection is closed
*
Expand Down Expand Up @@ -801,7 +820,7 @@ public void setIndividualBucketQuota(String userId, String bucket, long maxObjec
.url(urlBuilder.build())
.build();

safeCall(request);
call(request);
}

@Override
Expand Down Expand Up @@ -829,7 +848,7 @@ public void setUserQuota(String userId, String quotaType, long maxObjects, long
.url(urlBuilder.build())
.build();

safeCall(request);
call(request);
}

private String buildQuotaConfig(long maxObjects, long maxSizeKB) {
Expand Down

0 comments on commit d5c11e4

Please sign in to comment.