wrapped (IntArrayList) is always null, because not initialized.
java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.ints.IntArrayList.getInt(int)" because "this.wrapped" is null at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$MapIterator.nextEntry(Int2ObjectOpenHashMap.java:657) at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$EntryIterator.next(Int2ObjectOpenHashMap.java:750) at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$EntryIterator.next(Int2ObjectOpenHashMap.java:745)
example to reproduce:
Int2ObjectMap<Object> objects = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>(1)); final ObjectSet<Int2ObjectMap.Entry<Object>> entries = objects.int2ObjectEntrySet(); for (Int2ObjectMap.Entry<Object> entry : entries) { // <-- nextEntry NPE // some logic }
lib version: 8.5.8
Good day, why is it that when iterating a map, an NPE error always occurs because the internal collection has not been initialized.
MapIterator#nextEntry:L657
wrapped.getInt(-pos - 1);
wrapped (IntArrayList) is always null, because not initialized.
java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.ints.IntArrayList.getInt(int)" because "this.wrapped" is null at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$MapIterator.nextEntry(Int2ObjectOpenHashMap.java:657) at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$EntryIterator.next(Int2ObjectOpenHashMap.java:750) at it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap$EntryIterator.next(Int2ObjectOpenHashMap.java:745)
example to reproduce:
Int2ObjectMap<Object> objects = Int2ObjectMaps.synchronize(new Int2ObjectOpenHashMap<>(1)); final ObjectSet<Int2ObjectMap.Entry<Object>> entries = objects.int2ObjectEntrySet(); for (Int2ObjectMap.Entry<Object> entry : entries) { // <-- nextEntry NPE // some logic }
lib version: 8.5.8