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


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/lookup/HoodieLookupTableReader.java:
##########
@@ -77,12 +86,21 @@ public RowData read(RowData reuse) throws IOException {
     return null;
   }
 
+  @Override
   public void close() throws IOException {
-    if (this.inputFormat != null) {
-      inputFormat.close();
+    InputFormat format = this.inputFormat;
+    this.inputFormat = null;
+    this.inputSplits = null;
+    if (format == null) {
+      return;
     }
-    if (inputFormat instanceof RichInputFormat) {
-      ((RichInputFormat) inputFormat).closeInputFormat();
+
+    if (format instanceof RichInputFormat) {
+      try (Closeable ignored = ((RichInputFormat) format)::closeInputFormat) {
+        format.close();
+      }
+    } else {
+      format.close();
     }
   }
 }

Review Comment:
   🤖 nit: [Line 107] nit: `try (Closeable ignored = ((RichInputFormat) 
format)::closeInputFormat)` is a non-obvious pattern — a reader unfamiliar with 
the "method-reference-as-Closeable" trick could easily misread this as a no-op 
or wonder what `ignored` is for. A brief inline comment (e.g. `// ensures 
closeInputFormat() is called even if close() throws, with the exception 
suppressed`) would make the intent immediately clear, or a traditional 
try/finally block would be more idiomatic here.
   
   <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