findepi commented on code in PR #4863:
URL: https://github.com/apache/iceberg/pull/4863#discussion_r885269683


##########
core/src/main/java/org/apache/iceberg/util/Tasks.java:
##########
@@ -570,7 +584,7 @@ public static <I> Builder<I> foreach(I... items) {
   }
 
   public static <I> Builder<I> foreach(Stream<I> items) {
-    return new Builder<>(items::iterator);
+    return new Builder<>(items.iterator());

Review Comment:
   > No, `stream::iterator` will allow calling `iterator` more than once.
   
   I didn't know that, thanks!
   
   > Adding a single-use iterable would fix this 
   
   That's true. But `Iterable` interface contract isn't clear about whether "a 
single-use iterable" is a valid implementation, so I wouldn't want to create 
such a class. I wouldn't stop you if you wanted to, though. 
   
   > without lots of code changes. 
   
   from long-term design perspective this may or may not be a dominant factor



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