diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java index 47dc3f754f48b..14829a066ca3a 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/S3BlobContainer.java @@ -62,6 +62,7 @@ import software.amazon.awssdk.services.s3.model.UploadPartRequest; import software.amazon.awssdk.services.s3.model.UploadPartResponse; import software.amazon.awssdk.services.s3.paginators.ListObjectsV2Iterable; +import software.amazon.awssdk.utils.CollectionUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -591,7 +592,7 @@ void executeSingleUpload( .acl(blobStore.getCannedACL()) .overrideConfiguration(o -> o.addMetricPublisher(blobStore.getStatsMetricPublisher().putObjectMetricPublisher)); - if (metadata != null && !metadata.isEmpty()) { + if (CollectionUtils.isNotEmpty(metadata)) { putObjectRequestBuilder = putObjectRequestBuilder.metadata(metadata); } if (blobStore.serverSideEncryption()) { @@ -648,7 +649,7 @@ void executeMultipartUpload( .acl(blobStore.getCannedACL()) .overrideConfiguration(o -> o.addMetricPublisher(blobStore.getStatsMetricPublisher().multipartUploadMetricCollector)); - if (metadata != null && !metadata.isEmpty()) { + if (CollectionUtils.isNotEmpty(metadata)) { createMultipartUploadRequestBuilder.metadata(metadata); } diff --git a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/async/AsyncTransferManager.java b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/async/AsyncTransferManager.java index 007fe77825b2a..80538059d17b8 100644 --- a/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/async/AsyncTransferManager.java +++ b/plugins/repository-s3/src/main/java/org/opensearch/repositories/s3/async/AsyncTransferManager.java @@ -22,6 +22,7 @@ import software.amazon.awssdk.services.s3.model.DeleteObjectRequest; import software.amazon.awssdk.services.s3.model.PutObjectRequest; import software.amazon.awssdk.services.s3.model.S3Exception; +import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.CompletableFutureUtils; import org.apache.logging.log4j.LogManager; @@ -132,7 +133,7 @@ private void uploadInParts( .key(uploadRequest.getKey()) .overrideConfiguration(o -> o.addMetricPublisher(statsMetricPublisher.multipartUploadMetricCollector)); - if (uploadRequest.getMetadata() != null && !uploadRequest.getMetadata().isEmpty()) { + if (CollectionUtils.isNotEmpty(uploadRequest.getMetadata())) { createMultipartUploadRequestBuilder.metadata(uploadRequest.getMetadata()); } if (uploadRequest.doRemoteDataIntegrityCheck()) { @@ -332,7 +333,7 @@ private void uploadInOneChunk( .contentLength(uploadRequest.getContentLength()) .overrideConfiguration(o -> o.addMetricPublisher(statsMetricPublisher.putObjectMetricPublisher)); - if (uploadRequest.getMetadata() != null && !uploadRequest.getMetadata().isEmpty()) { + if (CollectionUtils.isNotEmpty(uploadRequest.getMetadata())) { putObjectRequestBuilder.metadata(uploadRequest.getMetadata()); } if (uploadRequest.doRemoteDataIntegrityCheck()) { diff --git a/server/src/main/java/org/opensearch/common/blobstore/FetchBlobResult.java b/server/src/main/java/org/opensearch/common/blobstore/FetchBlobResult.java index 5e1a13a17e798..55aca771b586c 100644 --- a/server/src/main/java/org/opensearch/common/blobstore/FetchBlobResult.java +++ b/server/src/main/java/org/opensearch/common/blobstore/FetchBlobResult.java @@ -8,6 +8,8 @@ package org.opensearch.common.blobstore; +import org.opensearch.common.annotation.ExperimentalApi; + import java.io.InputStream; import java.util.Map; @@ -17,6 +19,7 @@ * * @opensearch.experimental */ +@ExperimentalApi public class FetchBlobResult { /**