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


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/format/cdc/CdcIterators.java:
##########
@@ -135,14 +153,25 @@ public boolean hasNext() {
     }
 
     @Override
-    public RowData next() {
+    public synchronized RowData next() {
+      if (closed) {
+        throw new NoSuchElementException("CDC file-splits iterator was closed 
during teardown");
+      }
+      if (recordIterator == null) {
+        throw new NoSuchElementException("No more CDC records");
+      }
       return recordIterator.next();
     }
 
     @Override
-    public void close() {
+    public synchronized void close() {
+      if (closed) {
+        return;
+      }
+      closed = true;
       if (recordIterator != null) {
         recordIterator.close();
+        recordIterator = null;
       }
       if (imageManager != null) {
         imageManager.close();

Review Comment:
   🤖 nit: `recordIterator` is nulled out right after `recordIterator.close()` 
(line 174), but `imageManager` is left non-null after its `close()` here. Could 
you null it out for consistency, or add a brief comment if the asymmetry is 
intentional?
   
   <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