ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115344628
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -573,7 +541,7 @@ public Response head(
OzoneKey key;
try {
if (S3Owner.hasBucketOwnershipVerificationConditions(getHeaders())) {
- OzoneBucket bucket = getBucket(bucketName);
+ OzoneBucket bucket = getVolume().getBucket(bucketName);
S3Owner.verifyBucketOwnerCondition(getHeaders(), bucketName,
bucket.getOwner());
}
Review Comment:
Similar to `GET` and `PUT`, any plan to implement `handleHeadRequest` with
`ObjectRequestContext`?
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/exception/OS3Exception.java:
##########
@@ -66,31 +66,16 @@ public OS3Exception() {
//Added for JaxB.
}
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param requestIdVal
- * @param resourceVal
- */
- public OS3Exception(String codeVal, String messageVal, String requestIdVal,
- String resourceVal) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.requestId = requestIdVal;
- this.resource = resourceVal;
- }
+ OS3Exception(S3ErrorTable error, Exception cause, String resource) {
+ super(error.getErrorMessage(), cause);
- /**
- * Create an object OS3Exception.
- * @param codeVal
- * @param messageVal
- * @param httpCode
- */
- public OS3Exception(String codeVal, String messageVal, int httpCode) {
- this.code = codeVal;
- this.errorMessage = messageVal;
- this.httpCode = httpCode;
+ code = error.getCode();
+ errorMessage = error.getErrorMessage();
+ httpCode = error.getHttpCode();
+ this.resource = resource;
+
+ // logging in S3ErrorTable to respect any existing log level setting
+ S3ErrorTable.log(this);
Review Comment:
Can I check whether this is violating Safe Construction principle?
From Java Concurrency in Practice:
"An object is in a predictable, consistent state only after its constructor
returns, so publishing an object from within its constructor can publish an
incompletely constructed object. This is true even if the publication is the
last statement in the constructor"
##########
hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java:
##########
@@ -988,15 +935,13 @@ private Response createMultipartKey(OzoneVolume volume,
OzoneBucket ozoneBucket,
}
if (ex.getResult() == ResultCodes.NO_SUCH_MULTIPART_UPLOAD_ERROR) {
throw newError(NO_SUCH_UPLOAD, uploadID, ex);
- } else if (isAccessDenied(ex)) {
- throw newError(S3ErrorTable.ACCESS_DENIED, bucketName + "/" + key, ex);
} else if (ex.getResult() == ResultCodes.INVALID_PART) {
OS3Exception os3Exception = newError(
S3ErrorTable.INVALID_ARGUMENT, String.valueOf(partNumber), ex);
os3Exception.setErrorMessage(ex.getMessage());
throw os3Exception;
}
- throw ex;
+ throw newError(bucketName, key, ex);
Review Comment:
Seems for ACCESS_DENIED the resource changes from `bucketName + "/" + key`
to `key`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]