From faf84a2a01a37e6736ff16aa6099b0fe0207635b Mon Sep 17 00:00:00 2001 From: yuyang wang <39869597+Jackson-Wang-7@users.noreply.github.com> Date: Mon, 8 May 2023 18:35:31 +0800 Subject: [PATCH] Avoid the NPE exception in copy object with x-amz-tagging-directive ### What changes are proposed in this pull request? Avoid the NPE exception in copy object with x-amz-tagging-directive ### Why are the changes needed? Avoid the NPE exception pr-link: Alluxio/alluxio#17400 change-id: cid-db0f6ac83b1f6de7937c17f82911b153fe63155d --- .../main/java/alluxio/proxy/s3/S3RestServiceHandler.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/server/proxy/src/main/java/alluxio/proxy/s3/S3RestServiceHandler.java b/core/server/proxy/src/main/java/alluxio/proxy/s3/S3RestServiceHandler.java index 7d7968eefdfa..465b0f074a4a 100644 --- a/core/server/proxy/src/main/java/alluxio/proxy/s3/S3RestServiceHandler.java +++ b/core/server/proxy/src/main/java/alluxio/proxy/s3/S3RestServiceHandler.java @@ -971,6 +971,14 @@ public Response createObjectOrUploadPart(@HeaderParam("Content-MD5") final Strin throw new S3Exception("Copying an object to itself invalid.", objectPath, S3ErrorCode.INVALID_REQUEST); } + // avoid the NPE of status + try { + if (status == null) { + status = userFs.getStatus(new AlluxioURI(copySource)); + } + } catch (Exception e) { + throw S3RestUtils.toObjectS3Exception(e, objectPath, auditContext); + } try (FileInStream in = userFs.openFile(new AlluxioURI(copySource)); RangeFileInStream ris = RangeFileInStream.Factory.create(in, status.getLength(), s3Range);