JCLOUDS-1368: Fix off-by-one in slicing algorithm

This commit is contained in:
Andrew Gaul 2018-02-08 21:00:33 -08:00
parent 90498ae04d
commit eb5db026da
2 changed files with 3 additions and 1 deletions

View File

@ -360,7 +360,7 @@ public abstract class BaseBlobStore implements BlobStore {
long partSize = algorithm.calculateChunkSize(contentLength);
int partNumber = 1;
// TODO: for InputStream payloads, this buffers all parts in-memory!
while (partNumber < algorithm.getParts()) {
while (partNumber <= algorithm.getParts()) {
Payload payload = slicer.slice(blob.getPayload(), algorithm.getCopied(), partSize);
BlobUploader b =
new BlobUploader(mpu, partNumber++, payload);

View File

@ -828,6 +828,8 @@ public class BaseBlobIntegrationTest extends BaseBlobStoreIntegrationTest {
assertThat(etag).isNotNull();
Blob blob = blobStore.getBlob(container, blobName);
assertThat(blob.getMetadata().getContentMetadata().getContentLength()).isEqualTo(length);
InputStream is = null;
try {
is = blob.getPayload().openStream();