From 2a2a433b14369d0775e8c22ca19b0a308524212d Mon Sep 17 00:00:00 2001 From: alluxio-bot Date: Thu, 5 Sep 2024 02:15:07 -0700 Subject: [PATCH] Avoid the NPE exception in copy object with x-amz-tagging-directive Cherry-pick of existing commit. orig-pr: Alluxio/alluxio#17400 orig-commit: Alluxio/alluxio@abf9e6c66a805d38547d9e8e2911d8f28c4cc6d6 orig-commit-author: yuyang wang <39869597+Jackson-Wang-7@users.noreply.github.com> pr-link: Alluxio/alluxio#18686 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 669d36d7dbcf..3159e1c9dccc 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 @@ -984,6 +984,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);