Skip to content

Commit

Permalink
S3OutputStream: Don't complete multipart upload on finalize (#10874)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonf20 authored Aug 20, 2024
1 parent 2f2c367 commit b76d81a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions aws/src/main/java/org/apache/iceberg/aws/s3/S3OutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ private void newStream() throws IOException {

@Override
public void close() throws IOException {
close(true);
}

private void close(boolean completeUploads) throws IOException {
if (closed) {
return;
}
Expand All @@ -262,7 +266,9 @@ public void close() throws IOException {

try {
stream.close();
completeUploads();
if (completeUploads) {
completeUploads();
}
} finally {
cleanUpStagingFiles();
}
Expand Down Expand Up @@ -480,7 +486,7 @@ private void createStagingDirectoryIfNotExists() throws IOException, SecurityExc
protected void finalize() throws Throwable {
super.finalize();
if (!closed) {
close(); // releasing resources is more important than printing the warning
close(false); // releasing resources is more important than printing the warning
String trace = Joiner.on("\n\t").join(Arrays.copyOfRange(createStack, 1, createStack.length));
LOG.warn("Unclosed output stream created by:\n\t{}", trace);
}
Expand Down

0 comments on commit b76d81a

Please sign in to comment.