goldmansachs / gs-collections

GS Collections has been migrated to the Eclipse Foundation, re-branded as Eclipse Collections. https://www.eclipse.org/collections/
https://www.eclipse.org/collections/
1.81k stars 276 forks source link

ArrayIndexOutOfBoundsException while iterating over UnifiedMap #24

Closed yeison closed 9 years ago

yeison commented 9 years ago

I was iterating over a unifiedMap using values view and hit an ArrayIndexOutOfBoundsException

for (Object o : unifiedMap.valuesView()) 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1048576
    at com.gs.collections.impl.map.mutable.UnifiedMap$ValuesIterator.next(UnifiedMap.java:2564)
    at com.gs.collections.impl.UnmodifiableIteratorAdapter.next(UnmodifiableIteratorAdapter.java:42)
    at com.gs.futures.lexicon.product.client.components.InstrumentCache.unionOfChildMapsAsInstrumentList(InstrumentCache.java:471)
yeison commented 9 years ago

If I just use values() instead of valuesView() I'm able to avoid the error

motlin commented 9 years ago

Do you mutate the UnifiedMap inside the loop? Do you have any additional information that would help reproduce the exception?

yeison commented 9 years ago

Perhaps I am mutating my map somewhere else concurrently. When I add a lock the issue goes away and I can still use valuesView(). I'll close this ticket and continue to look into it. If I can reproduce it with the lock I'll let you know.