rdblue commented on code in PR #5887:
URL: https://github.com/apache/iceberg/pull/5887#discussion_r993611914


##########
core/src/main/java/org/apache/iceberg/util/ParallelIterable.java:
##########
@@ -81,13 +81,18 @@ private ParallelIterator(
 
     @Override
     public void close() {
+      // close first, avoid new task submit
+      this.closed = true;
+
       // cancel background tasks
       for (int i = 0; i < taskFutures.length; i += 1) {
-        if (taskFutures[i] != null && !taskFutures[i].isDone()) {
-          taskFutures[i].cancel(true);
+        Future<?> taskFuture = taskFutures[i];
+        if (taskFuture != null && !taskFuture.isDone()) {
+          taskFuture.cancel(true);
         }
       }
-      this.closed = true;
+      // clean queue
+      this.queue.clear();

Review Comment:
   I think the reason is that we didn't expect the iterator to last very long 
before getting garbage collected. It seems reasonable to clean up as early as 
possible though.



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