avian icon indicating copy to clipboard operation
avian copied to clipboard

ConcurrentHashMap.<someCollection>.toArray() can throw ArrayIndexOutOfBoundsexception

Open jentfoo opened this issue 10 years ago • 0 comments

I noticed this while looking for another issue. If you do ConcurrentHashMap.entrySet/values/keySet, and then try to call .toArray (weather an array is passed in or not). If the map structure grows after the .size() check in Data.toArray, the iterator will end up getting an extra element than the array that was allocated for it. Thus the out of bounds exception will be thrown when we try to store an element in the array we have not allocated for.

jentfoo avatar Dec 15 '14 16:12 jentfoo