Skip to content

Commit d18d7a2

Browse files
committed
Fix computation of last block size in Azure concurrent multipart uploads
Last part size is wrongly computed to 0 when the last part's length is exactly equal to the size of a part. Relates ES-11815
1 parent b286748 commit d18d7a2

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

modules/repository-azure/src/main/java/org/elasticsearch/repositories/azure/AzureBlobStore.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,9 @@ private static List<MultiPart> computeMultiParts(long totalSize, long partSize)
533533
return List.of(new MultiPart(0, makeMultipartBlockId(), 0L, totalSize, true));
534534
}
535535

536-
long lastPartSize = totalSize % partSize;
537-
int parts = Math.toIntExact(totalSize / partSize) + (0L < lastPartSize ? 1 : 0);
536+
long remaining = totalSize % partSize;
537+
int parts = Math.toIntExact(totalSize / partSize) + (0L < remaining ? 1 : 0);
538+
long lastPartSize = 0L < remaining ? remaining : partSize;
538539

539540
long blockOffset = 0L;
540541
var list = new ArrayList<MultiPart>(parts);

0 commit comments

Comments
 (0)