If map
is a local variable (and not an instance field), it is theoretically impossible to get an NPE on map.entrySet()
after map.entrySet().size()
already succeeded, even if the map itself was accessible to another thread and that thread changed it in every way imaginable. If the first entry in your stacktrace is a line of your code, as opposed to some code that was called from yours, then the only way for that to happen is for the map
variable itself to be null
. Therefore I think you need to revisit your diagnostic clues.