Skip to content

Commit

Permalink
Make close on streaming S3 OutputStream idempotent
Browse files Browse the repository at this point in the history
  • Loading branch information
losipiuk committed Feb 18, 2022
1 parent 7a60c35 commit 6396f8d
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,7 @@ private static class TrinoS3StreamingOutputStream
private byte[] buffer;
private int bufferSize;

private boolean closed;
private boolean failed;
// Mutated and read by main thread; mutated just before scheduling upload to background thread (access does not need to be thread safe)
private boolean multipartUploadStarted;
Expand Down Expand Up @@ -1548,6 +1549,11 @@ public void flush()
public void close()
throws IOException
{
if (closed) {
return;
}
closed = true;

if (failed) {
try {
abortUpload();
Expand Down

0 comments on commit 6396f8d

Please sign in to comment.