danny0405 commented on code in PR #18909:
URL: https://github.com/apache/hudi/pull/18909#discussion_r3360121227


##########
hudi-hadoop-common/src/main/java/org/apache/hudi/common/table/log/HoodieLogFormatWriter.java:
##########
@@ -245,14 +250,59 @@ public void close() throws IOException {
   }
 
   private void closeStream() throws IOException {
-    if (outputStream != null) {
+    if (outputStream == null) {
+      return;
+    }
+
+    Exception syncException = null;
+    try {
       // Persist all buffered data to DataNodes before closing so downstream
       // readers can observe a fully-written log file at commit-level 
visibility.
       sync();
-      outputStream.close();
-      outputStream = null;
-      closed = true;
+    } catch (Exception e) {
+      syncException = e;
+    }
+
+    try {
+      closeOutputStream();
+    } catch (IOException | RuntimeException closeException) {
+      if (syncException != null) {
+        syncException.addSuppressed(closeException);
+        rethrow(syncException);
+      }
+      rethrow(closeException);
+    }
+
+    if (syncException != null) {
+      rethrow(syncException);
+    }
+  }
+
+  private void closeOutputStreamOnAppendFailure(Throwable failure) {
+    try {
+      closeOutputStream();
+    } catch (IOException | RuntimeException closeException) {
+      failure.addSuppressed(closeException);
+      log.warn("Failed to close output stream after append failure for log 
file {}", logFile, closeException);
+    }
+  }
+
+  private void closeOutputStream() throws IOException {
+    if (outputStream != null) {
+      try {
+        outputStream.close();
+      } finally {
+        outputStream = null;
+        closed = true;
+      }
+    }
+  }
+
+  private void rethrow(Exception exception) throws IOException {

Review Comment:
   is this right? the method does not always throw IOException now?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to