diff options
| author | 2017-03-08 12:18:25 +0000 | |
|---|---|---|
| committer | 2017-03-08 12:18:28 +0000 | |
| commit | 137b460e5fb2e4426504ad5315688f2fd71b7354 (patch) | |
| tree | 0f88548a12b6ef916364dd9e9a3ff2a0addf7ebc | |
| parent | 07be4d67813bdda4479e0e5a482f76b3f52160e7 (diff) | |
| parent | 093572cd1b482a242c8996d2d2bccdf75bd33254 (diff) | |
Merge "Don't allow MapCollections to iterate past the end."
| -rw-r--r-- | core/java/android/util/MapCollections.java | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/core/java/android/util/MapCollections.java b/core/java/android/util/MapCollections.java index 28b788b97aa7..80ab23c8261d 100644 --- a/core/java/android/util/MapCollections.java +++ b/core/java/android/util/MapCollections.java @@ -22,6 +22,7 @@ import java.lang.reflect.Array; import java.util.Collection; import java.util.Iterator; import java.util.Map; +import java.util.NoSuchElementException; import java.util.Set; /** @@ -52,6 +53,7 @@ abstract class MapCollections<K, V> { @Override public T next() { + if (!hasNext()) throw new NoSuchElementException(); Object res = colGetEntry(mIndex, mOffset); mIndex++; mCanRemove = true; @@ -87,6 +89,7 @@ abstract class MapCollections<K, V> { @Override public Map.Entry<K, V> next() { + if (!hasNext()) throw new NoSuchElementException(); mIndex++; mEntryValid = true; return this; |