Skip to content

Commit

Permalink
Revert "Pipeline buffering and upload in S3 multi-upload"
Browse files Browse the repository at this point in the history
This reverts commit 7383734.
  • Loading branch information
linzebing authored and losipiuk committed Jan 21, 2022
1 parent 5313c35 commit 3fab98f
Showing 1 changed file with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,15 @@ public void close()
private void flushBuffer(boolean finished)
throws IOException
{
try {
waitForPreviousUploadFinish();
}
catch (IOException e) {
failed = true;
abortUploadSuppressed(e);
throw e;
}

// skip multipart upload if there would only be one part
if (finished && uploadId.isEmpty()) {
InputStream in = new ByteArrayInputStream(buffer, 0, bufferSize);
Expand All @@ -1587,7 +1596,6 @@ private void flushBuffer(boolean finished)
return;
}
catch (AmazonServiceException e) {
failed = true;
throw new IOException(e);
}
}
Expand All @@ -1596,23 +1604,8 @@ private void flushBuffer(boolean finished)
if (bufferSize == buffer.length || (finished && bufferSize > 0)) {
byte[] data = buffer;
int length = bufferSize;

if (finished) {
this.buffer = null;
}
else {
this.buffer = new byte[buffer.length];
bufferSize = 0;
}

try {
waitForPreviousUploadFinish();
}
catch (IOException e) {
failed = true;
abortUploadSuppressed(e);
throw e;
}
this.buffer = new byte[buffer.length];
bufferSize = 0;

inProgressUploadFuture = uploadExecutor.submit(() -> uploadPage(data, length));
}
Expand Down

0 comments on commit 3fab98f

Please sign in to comment.