From f80a7021d87267fbab5bbbe3ef81064fae474082 Mon Sep 17 00:00:00 2001 From: Bala FA Date: Fri, 14 Jun 2024 21:33:17 +0530 Subject: [PATCH] fix range calculation in composeObject API (#1553) Signed-off-by: Bala.FA --- api/src/main/java/io/minio/MinioAsyncClient.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/api/src/main/java/io/minio/MinioAsyncClient.java b/api/src/main/java/io/minio/MinioAsyncClient.java index a19cde085..c3bb1f691 100644 --- a/api/src/main/java/io/minio/MinioAsyncClient.java +++ b/api/src/main/java/io/minio/MinioAsyncClient.java @@ -769,15 +769,15 @@ public CompletableFuture composeObject(ComposeObjectArgs ar while (size > 0) { partNumber++; - long startBytes = offset; - long endBytes = startBytes + ObjectWriteArgs.MAX_PART_SIZE; - if (size < ObjectWriteArgs.MAX_PART_SIZE) - endBytes = startBytes + size; + long length = size; + if (length > ObjectWriteArgs.MAX_PART_SIZE) { + length = ObjectWriteArgs.MAX_PART_SIZE; + } + long endBytes = offset + length - 1; Multimap headersCopy = newMultimap(headers); headersCopy.put( - "x-amz-copy-source-range", - "bytes=" + startBytes + "-" + endBytes); + "x-amz-copy-source-range", "bytes=" + offset + "-" + endBytes); final int partNum = partNumber; future = @@ -801,8 +801,8 @@ public CompletableFuture composeObject(ComposeObjectArgs ar throw new CompletionException(e); } }); - offset = startBytes; - size -= (endBytes - startBytes); + offset += length; + size -= length; } }