diff --git a/src/main/java/org/apache/commons/collections4/IteratorUtils.java b/src/main/java/org/apache/commons/collections4/IteratorUtils.java index a4d9d8614..4cae230de 100644 --- a/src/main/java/org/apache/commons/collections4/IteratorUtils.java +++ b/src/main/java/org/apache/commons/collections4/IteratorUtils.java @@ -712,11 +712,9 @@ public class IteratorUtils { */ public static void forEach(final Iterator iterator, final Closure closure) { Objects.requireNonNull(closure, "closure"); - if (iterator != null) { while (iterator.hasNext()) { - final E element = iterator.next(); - closure.accept(element); + closure.accept(iterator.next()); } } }