Skip to content

Commit a0945e8

Browse files
Merge pull request #3629 from tronprotocol/hotfix/addnseexcpetion
add NoSuchElementException
2 parents 1364c9c + 695644f commit a0945e8

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

common/src/main/java/org/tron/common/utils/ByteArrayMap.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.HashMap;
2525
import java.util.Iterator;
2626
import java.util.Map;
27+
import java.util.NoSuchElementException;
2728
import java.util.Set;
2829
import org.tron.core.db.ByteArrayWrapper;
2930

@@ -154,6 +155,9 @@ public boolean hasNext() {
154155

155156
@Override
156157
public Entry<byte[], V> next() {
158+
if (!hasNext()) {
159+
throw new NoSuchElementException();
160+
}
157161
Entry<ByteArrayWrapper, V> next = it.next();
158162
return Maps.immutableEntry(next.getKey().getData(), next.getValue());
159163
}

common/src/main/java/org/tron/common/utils/ByteArraySet.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Collection;
2323
import java.util.HashSet;
2424
import java.util.Iterator;
25+
import java.util.NoSuchElementException;
2526
import java.util.Set;
2627
import org.tron.core.db.ByteArrayWrapper;
2728

@@ -68,6 +69,9 @@ public boolean hasNext() {
6869

6970
@Override
7071
public byte[] next() {
72+
if (!hasNext()) {
73+
throw new NoSuchElementException();
74+
}
7175
return it.next().getData();
7276
}
7377

0 commit comments

Comments
 (0)