Closed
Description
Christoph Strobl opened SPR-16584 and commented
ConcurrentReferenceHashMap
needs to override the default implementation of computeIfAbsent
in order to allow adding computed null
values.
#from: ConcurrentMap.java
... implementation assumes that the
ConcurrentMap
cannot containnull
values andget()
returningnull
unambiguously means the key is absent. Implementations which supportnull
values must override this default implementation.
The following currently fails:
ConcurrentReferenceHashMap<String, Object> map = new ConcurrentReferenceHashMap<>();
map.computeIfAbsent("key", key -> null);
assertThat(map.containsKey("key")).isTrue();
Affects: 4.3.14, 5.0.4
Issue Links:
- LinkedCaseInsensitiveMap doesn't implement getOrDefault properly [SPR-13981] #18553 LinkedCaseInsensitiveMap doesn't implement getOrDefault properly
- LinkedCaseInsensitiveMap cannot access locale from subclass [SPR-15752] #20307 LinkedCaseInsensitiveMap cannot access locale from subclass
- ConcurrentReferenceHashMap does not enforce visibility of cached EntrySet [SPR-16994] #21532 ConcurrentReferenceHashMap does not enforce visibility of cached EntrySet
Referenced from: commits 8d8bb04, 356ef45
Backported to: 4.3.15