We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bb57cde commit dc3ad5eCopy full SHA for dc3ad5e
util/src/main/java/com/ibm/wala/util/collections/IteratorPlusOne.java
@@ -11,6 +11,7 @@
11
package com.ibm.wala.util.collections;
12
13
import java.util.Iterator;
14
+import java.util.NoSuchElementException;
15
import org.jspecify.annotations.Nullable;
16
17
/** A utility to efficiently compose an iterator and a singleton */
@@ -37,15 +38,18 @@ public boolean hasNext() {
37
38
return it.hasNext() || (xtra != null);
39
}
40
- @Nullable
41
@Override
42
public T next() {
43
if (it.hasNext()) {
44
return it.next();
45
} else {
46
T result = xtra;
47
- xtra = null;
48
- return result;
+ if (result != null) {
+ xtra = null;
49
+ return result;
50
+ } else {
51
+ throw new NoSuchElementException();
52
+ }
53
54
55
0 commit comments