ivandika3 commented on code in PR #10097:
URL: https://github.com/apache/ozone/pull/10097#discussion_r3115375064
##########
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 practices?
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"
The workaround seem to use a public static factory method.
--
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]