Files
floci/src/test/java
Niels Kootstra 0e432dd41b perf(s3): assemble multipart uploads without doubling the object in heap (#4227)
* perf(s3): assemble multipart uploads without doubling the object in heap

CompleteMultipartUpload read every part with Files.readAllBytes into a growing
ByteArrayOutputStream and then copied it again with toByteArray(), so a
disk-backed upload briefly held several full-size copies of the object.

Size one array from the part lengths and read each part straight into its
slot, failing if a part changes size during assembly rather than producing a
corrupt object. The composite ETag and full-object checksum are unchanged.

* fix(s3): fail multipart assembly when a part grows after being measured

The size check caught a part that shrank between being measured and
being copied, but not one that grew: the read stopped at the measured
size and the extra bytes were dropped. Disk parts are now checked for
end of file after the measured bytes, and in-memory parts are copied
from the arrays that were measured, whose length cannot change.

* chore: rerun CI
2026-09-23 13:56:29 -04:00
..