hudi-agent commented on code in PR #19778:
URL: https://github.com/apache/hudi/pull/19778#discussion_r4127226350


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -1661,12 +1691,38 @@ public void releaseResources(String instantTime) {
 
   @Override
   public void close() {
-    // Stop timeline-server if running
-    super.close();
-    // Calling this here releases any resources used by your index, so make 
sure to finish any related operations
-    // before this point
-    this.index.close();
-    this.tableServiceClient.close();
+    // The index and the table service client are this class's own resources; 
a failure while the
+    // base client releases its own must not leave them open.
+    Exception failure = null;
+    try {
+      // Stop timeline-server if running
+      super.close();
+    } catch (Exception e) {
+      failure = e;
+    }
+    try {
+      // Calling this here releases any resources used by your index, so make 
sure to finish any related operations
+      // before this point
+      this.index.close();
+    } catch (Exception e) {
+      failure = appendFailure(failure, e);
+    }
+    try {
+      this.tableServiceClient.close();
+    } catch (Exception e) {
+      failure = appendFailure(failure, e);
+    }
+    if (failure != null) {
+      throw failure instanceof RuntimeException ? (RuntimeException) failure : 
new HoodieException(failure);
+    }
+  }
+
+  private static Exception appendFailure(Exception previousFailure, Exception 
failure) {

Review Comment:
   🤖 nit: `appendFailure` is an exact copy of the one in `BaseHoodieClient`. 
Could you make that one `protected static` and reuse it here? A small 
`closeQuietly(Runnable, failure)`-style helper might also cut down the repeated 
try/catch blocks in both `close()` methods and in `SparkRDDWriteClient`.
   
   <sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag 
quality.</i></sub>



-- 
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