diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java index dbf8cf31e319..398a6bafe43a 100644 --- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java +++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/BucketEndpoint.java @@ -241,12 +241,12 @@ public Response put(@PathParam("bucket") String bucketName, return Response.status(HttpStatus.SC_OK).header("Location", location) .build(); } catch (OMException exception) { - LOG.error("Error in Create Bucket Request for bucket: {}", bucketName, - exception); if (exception.getResult() == ResultCodes.INVALID_BUCKET_NAME) { throw S3ErrorTable.newError(S3ErrorTable.INVALID_BUCKET_NAME, bucketName); } + LOG.error("Error in Create Bucket Request for bucket: {}", bucketName, + exception); throw exception; } } @@ -291,12 +291,7 @@ public Response listMultipartUploads( @HEAD public Response head(@PathParam("bucket") String bucketName) throws OS3Exception, IOException { - try { - getBucket(bucketName); - } catch (OS3Exception ex) { - LOG.error("Exception occurred in headBucket", ex); - throw ex; - } + getBucket(bucketName); return Response.ok().build(); } @@ -507,8 +502,6 @@ public Response putAcl(String bucketName, HttpHeaders httpHeaders, volume.addAcl(acl); } } catch (OMException exception) { - LOG.error("Error in set ACL Request for bucket: {}", bucketName, - exception); if (exception.getResult() == ResultCodes.BUCKET_NOT_FOUND) { throw S3ErrorTable.newError(S3ErrorTable.NO_SUCH_BUCKET, bucketName); @@ -516,6 +509,8 @@ public Response putAcl(String bucketName, HttpHeaders httpHeaders, throw S3ErrorTable.newError(S3ErrorTable .ACCESS_DENIED, bucketName); } + LOG.error("Error in set ACL Request for bucket: {}", bucketName, + exception); throw exception; } return Response.status(HttpStatus.SC_OK).build(); diff --git a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java index d2a45b1776e8..c829a96d9b63 100644 --- a/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java +++ b/hadoop-ozone/s3gateway/src/main/java/org/apache/hadoop/ozone/s3/endpoint/ObjectEndpoint.java @@ -208,23 +208,20 @@ public Response put( return Response.ok().status(HttpStatus.SC_OK) .build(); - } catch (IOException ex) { - LOG.error("Exception occurred in PutObject", ex); - if (ex instanceof OMException) { - if (((OMException) ex).getResult() == ResultCodes.NOT_A_FILE) { - OS3Exception os3Exception = S3ErrorTable.newError(INVALID_REQUEST, - keyPath); - os3Exception.setErrorMessage("An error occurred (InvalidRequest) " + - "when calling the PutObject/MPU PartUpload operation: " + - OZONE_OM_ENABLE_FILESYSTEM_PATHS + " is enabled Keys are" + - " considered as Unix Paths. Path has Violated FS Semantics " + - "which caused put operation to fail."); - throw os3Exception; - } else if ((((OMException) ex).getResult() == - ResultCodes.PERMISSION_DENIED)) { - throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, keyPath); - } + } catch (OMException ex) { + if (ex.getResult() == ResultCodes.NOT_A_FILE) { + OS3Exception os3Exception = S3ErrorTable.newError(INVALID_REQUEST, + keyPath); + os3Exception.setErrorMessage("An error occurred (InvalidRequest) " + + "when calling the PutObject/MPU PartUpload operation: " + + OZONE_OM_ENABLE_FILESYSTEM_PATHS + " is enabled Keys are" + + " considered as Unix Paths. Path has Violated FS Semantics " + + "which caused put operation to fail."); + throw os3Exception; + } else if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { + throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, keyPath); } + LOG.error("Exception occurred in PutObject", ex); throw ex; } finally { if (output != null) { @@ -497,11 +494,11 @@ public Response initializeMultipartUpload( return Response.status(Status.OK).entity( multipartUploadInitiateResponse).build(); } catch (OMException ex) { - LOG.error("Error in Initiate Multipart Upload Request for bucket: {}, " + - "key: {}", bucket, key, ex); if (ex.getResult() == ResultCodes.PERMISSION_DENIED) { throw S3ErrorTable.newError(S3ErrorTable.ACCESS_DENIED, key); } + LOG.error("Error in Initiate Multipart Upload Request for bucket: {}, " + + "key: {}", bucket, key, ex); throw ex; } } @@ -544,8 +541,6 @@ public Response completeMultipartUpload(@PathParam("bucket") String bucket, return Response.status(Status.OK).entity(completeMultipartUploadResponse) .build(); } catch (OMException ex) { - LOG.error("Error in Complete Multipart Upload Request for bucket: {}, " + - ", key: {}", bucket, key, ex); if (ex.getResult() == ResultCodes.INVALID_PART) { throw S3ErrorTable.newError(S3ErrorTable.INVALID_PART, key); } else if (ex.getResult() == ResultCodes.INVALID_PART_ORDER) { @@ -569,6 +564,8 @@ public Response completeMultipartUpload(@PathParam("bucket") String bucket, "given KeyName caused failure for MPU"); throw os3Exception; } + LOG.error("Error in Complete Multipart Upload Request for bucket: {}, " + + ", key: {}", bucket, key, ex); throw ex; } }