Skip to content

Commit f80a702

Browse files
authored
fix range calculation in composeObject API (#1553)
Signed-off-by: Bala.FA <bala@minio.io>
1 parent ae87105 commit f80a702

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

api/src/main/java/io/minio/MinioAsyncClient.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -769,15 +769,15 @@ public CompletableFuture<ObjectWriteResponse> composeObject(ComposeObjectArgs ar
769769
while (size > 0) {
770770
partNumber++;
771771

772-
long startBytes = offset;
773-
long endBytes = startBytes + ObjectWriteArgs.MAX_PART_SIZE;
774-
if (size < ObjectWriteArgs.MAX_PART_SIZE)
775-
endBytes = startBytes + size;
772+
long length = size;
773+
if (length > ObjectWriteArgs.MAX_PART_SIZE) {
774+
length = ObjectWriteArgs.MAX_PART_SIZE;
775+
}
776+
long endBytes = offset + length - 1;
776777

777778
Multimap<String, String> headersCopy = newMultimap(headers);
778779
headersCopy.put(
779-
"x-amz-copy-source-range",
780-
"bytes=" + startBytes + "-" + endBytes);
780+
"x-amz-copy-source-range", "bytes=" + offset + "-" + endBytes);
781781

782782
final int partNum = partNumber;
783783
future =
@@ -801,8 +801,8 @@ public CompletableFuture<ObjectWriteResponse> composeObject(ComposeObjectArgs ar
801801
throw new CompletionException(e);
802802
}
803803
});
804-
offset = startBytes;
805-
size -= (endBytes - startBytes);
804+
offset += length;
805+
size -= length;
806806
}
807807
}
808808

0 commit comments

Comments
 (0)