Skip to content

Commit 078eb83

Browse files
committed
Add check for hasNext in PrimitiveVector.iterator
1 parent 0871535 commit 078eb83

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/src/main/scala/org/apache/spark/util/collection/PrimitiveVector.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ class PrimitiveVector[@specialized(Long, Int, Double) V: ClassTag](initialSize:
5454
var index = 0
5555
override def hasNext: Boolean = index < _numElements
5656
override def next(): V = {
57+
if (!hasNext) {
58+
throw new NoSuchElementException
59+
}
5760
val value = _array(index)
5861
index += 1
5962
value

0 commit comments

Comments
 (0)