Should HashMap::computeIfAbsent be considered a "structural modification" for an existing key?
Michael Rasmussen
Michael.Rasmussen at roguewave.com
Mon Nov 19 23:52:25 UTC 2018
From: Andrew Dinn <adinn at redhat.com>
> I have to ask the obvious: Why does the question matter?
I'm trying to figure out if something is a bug in HashMap in the JDK, or in Weld :D
The case in question is basically, a HashMap is created, and then the keys are iterated over concurrently.
The issue here though is that the HashMap is used as the backing of a MultiMap, and the multimap.get is basically hashmap.computeIfAbsent(key, k -> new HashSet()).
Meaning you have a HashMap, which you've fully initialized, and you're iterating over all the known keys in the map... but surprisingly the call to .get actually changes the structure of the map, leading to bad consequences.
/Michael
More information about the core-libs-dev
mailing list