Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.12.2
-
None
-
Unknown
Description
According to the java.util.Iterator#next() contract the implementation should throw NoSuchElementException if the iteration has no more elements. However this is currently not the case by the different anonymous class implemetations of this interface through ObjectHelper#createIterator().
The side effect of this is that currently this could end up with IndexOutOfBoundsException and what not if one would iterate over the Node(s) of a DOM NodeList. Another example is that calling next() on the Iterator returned for an empty String repeatedly doesn't throw any NoSuchElementException although it's hasNext() method returns false!
We should better provide guards for the condition when there's no more elements available in which case a NoSuchElementException should be thrown.