saurabhagas commented on a change in pull request #2881:
URL: https://github.com/apache/iceberg/pull/2881#discussion_r678060762



##########
File path: api/src/main/java/org/apache/iceberg/io/ClosingIterator.java
##########
@@ -25,33 +25,30 @@
 
 public class ClosingIterator<T> implements Iterator<T> {
   private final CloseableIterator<T> iterator;
-  private boolean shouldClose = false;
 
   public ClosingIterator(CloseableIterator<T> iterator) {
     this.iterator = iterator;
-
   }
 
   @Override
   public boolean hasNext() {
     boolean hasNext = iterator.hasNext();
-    this.shouldClose = !hasNext;
+    if (!hasNext) {
+      close();

Review comment:
       `Closeable::close` is required to be idempotent - if calling close on a 
`Closeable` resource has any side-effects, we should fix that at the source. 
This would also mean that calling close() multiple times should not throw any 
exceptions.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to