Now can anybody explain to me, how the hell does this happen? Can you spot this concurrent modification the JVM is complaining about??
When an iterator is working through a collection, you are not allowed to change the structural organization of the collection. It is not really a concurrent modification -- it is more of a modification while the iterator is still working on it.
Anyway, to answer your question, you configured you linked hash map to keep access order. This means that an access of any kind can change the structural organization of the map. Your get() method is basically changing the structure of the map, while you are still iterating, hence, concurrent modification exception.
You get a Set from the entrySet method. Now your Map is parameterised as <String, String>, so your Set will contain Entries of that type. It will read something like this:I think that is how it works. You do not keep the insertion order like this, I am afraid. [ July 18, 2008: Message edited by: Campbell Ritchie ]
Joined: Jul 11, 2008
Hello and thank you for your insights! If anybody's interested in such details: I've just tested the entrySet() iteration and it seems that neither entry.getKey() nor entry.getValue() count as access in this case, so the insertion order remains actually intact.