This is an automated email from the ASF dual-hosted git repository.

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-paimon.git


The following commit(s) were added to refs/heads/master by this push:
     new 7062d7a6a [core] Exception should be thrown after 'catch' in 
`AppendOnlyWriter` (#2948)
7062d7a6a is described below

commit 7062d7a6a71a1bc6bd378bdb8e6c4ab322834eaf
Author: YeJunHao <[email protected]>
AuthorDate: Wed Mar 6 12:41:44 2024 +0800

    [core] Exception should be thrown after 'catch' in `AppendOnlyWriter` 
(#2948)
---
 .../src/main/java/org/apache/paimon/append/AppendOnlyWriter.java | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git 
a/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java 
b/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java
index b8344b301..f61083f11 100644
--- a/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java
+++ b/paimon-core/src/main/java/org/apache/paimon/append/AppendOnlyWriter.java
@@ -37,6 +37,7 @@ import org.apache.paimon.statistics.FieldStatsCollector;
 import org.apache.paimon.types.RowKind;
 import org.apache.paimon.types.RowType;
 import org.apache.paimon.utils.CommitIncrement;
+import org.apache.paimon.utils.IOUtils;
 import org.apache.paimon.utils.LongCounter;
 import org.apache.paimon.utils.Preconditions;
 import org.apache.paimon.utils.RecordWriter;
@@ -379,11 +380,19 @@ public class AppendOnlyWriter implements 
RecordWriter<InternalRow>, MemoryOwner
             if (writeBuffer != null) {
                 writeBuffer.complete();
                 RowDataRollingFileWriter writer = createRollingRowWriter();
+                IOException exception = null;
                 try (RowBuffer.RowBufferIterator iterator = 
writeBuffer.newIterator()) {
                     while (iterator.advanceNext()) {
                         writer.write(iterator.getRow());
                     }
+                } catch (IOException e) {
+                    exception = e;
                 } finally {
+                    if (exception != null) {
+                        IOUtils.closeQuietly(writer);
+                        // cleanup code that might throw another exception
+                        throw exception;
+                    }
                     writer.close();
                 }
                 flushedFiles.addAll(writer.result());

Reply via email to