stevenzwu commented on code in PR #5642:
URL: https://github.com/apache/iceberg/pull/5642#discussion_r960196838


##########
flink/v1.15/flink/src/main/java/org/apache/iceberg/flink/sink/IcebergStreamWriter.java:
##########
@@ -98,12 +102,21 @@ public String toString() {
         .toString();
   }
 
-  /** close all open files and emit files to downstream committer operator */
+  /**
+   * close all open files and emit files to downstream committer operator
+   */
   private void flush() throws IOException {
+    if (writer == null) {
+      return;
+    }
+
     long startNano = System.nanoTime();
     WriteResult result = writer.complete();
     writerMetrics.updateFlushResult(result);
     output.collect(new StreamRecord<>(result));
     
writerMetrics.flushDuration(TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - 
startNano));
+
+    // Set write to null to prevent multiple calls to the complete method of 
the same write

Review Comment:
   nit: maybe comment like this
   
   ```
   Set writer to null to prevent duplicate flushes in the corner case of 
prepareSnapshotPreBarrier happening after endInput. 
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to