Skip to content

Commit

Permalink
HDDS-12131. NPE in OM when overwriting empty file using multipart upl…
Browse files Browse the repository at this point in the history
…oad (#7739)
  • Loading branch information
k5342 authored Jan 24, 2025
1 parent c0a6ffd commit db059c6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 6 additions & 0 deletions hadoop-ozone/dist/src/main/smoketest/s3/MultipartUpload.robot
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Test Multipart Upload With Adjusted Length
Perform Multipart Upload ${BUCKET} multipart/adjusted_length_${PREFIX} /tmp/part1 /tmp/part2
Verify Multipart Upload ${BUCKET} multipart/adjusted_length_${PREFIX} /tmp/part1 /tmp/part2

Overwrite Empty File
Execute touch ${TEMP_DIR}/empty
Execute AWSS3Cli cp ${TEMP_DIR}/empty s3://${BUCKET}/empty_file_${PREFIX}
Perform Multipart Upload ${BUCKET} empty_file_${PREFIX} /tmp/part1 /tmp/part2
Verify Multipart Upload ${BUCKET} empty_file_${PREFIX} /tmp/part1 /tmp/part2

Test Multipart Upload
${uploadID} = Initiate MPU ${BUCKET} ${PREFIX}/multipartKey
${nextUploadID} = Initiate MPU ${BUCKET} ${PREFIX}/multipartKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.apache.hadoop.hdds.utils.db.BatchOperation;

import jakarta.annotation.Nonnull;
import jakarta.annotation.Nullable;

import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.BUCKET_TABLE;
import static org.apache.hadoop.ozone.om.OmMetadataManagerImpl.DELETED_TABLE;
Expand Down Expand Up @@ -130,6 +131,7 @@ protected OmKeyInfo getOmKeyInfo() {
return omKeyInfo;
}

@Nullable
protected OmBucketInfo getOmBucketInfo() {
return omBucketInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ public void addToDBBatch(OMMetadataManager omMetadataManager,
}

// namespace quota changes for parent directory
String bucketKey = omMetadataManager.getBucketKey(
getOmBucketInfo().getVolumeName(),
getOmBucketInfo().getBucketName());
omMetadataManager.getBucketTable().putWithBatch(batchOperation,
bucketKey, getOmBucketInfo());
OmBucketInfo omBucketInfo = getOmBucketInfo();
if (omBucketInfo != null) {
String bucketKey = omMetadataManager.getBucketKey(
omBucketInfo.getVolumeName(),
omBucketInfo.getBucketName());
omMetadataManager.getBucketTable().putWithBatch(batchOperation,
bucketKey, omBucketInfo);
}

if (OMFileRequest.getOmKeyInfoFromFileTable(true,
omMetadataManager, getMultiPartKey(), getOmKeyInfo().getKeyName())
Expand Down

0 comments on commit db059c6

Please sign in to comment.