Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locking overhead on Java 8 caused by ConcurrentHashMap.computeIfAbsent(…) [DATACMNS-1396] #1831

spring-projects-issues opened this issue Sep 25, 2018 · 0 comments
in: mapping type: enhancement


Copy link

spring-projects-issues commented Sep 25, 2018

Akshay Gehi opened DATACMNS-1396 and commented

ConcurrentHashMap.computeIfAbsent(k,f) locks bin when k present - this is documented in the following bug report

Classes such as the ones mentioned below make use of computeIfAbsent without considering the impact of the above JDK issue. This causes a bottleneck while processing large MongoDB documents with complex arrays in them. This issue may be seen in other scenarios too because its fairly generic

Classes and methods affected:




Proposed fix:

Call get before calling computeIfAbsent

            V value = map.get(key); 
             if (value == null) { 
                 value = map.computeIfAbsent(key, function); 
             return value

Affects: 2.0.10 (Kay SR10), 2.1 GA (Lovelace)


Referenced from: pull request #319

Backported to: 2.1.1 (Lovelace SR1), 2.0.11 (Kay SR11)

@spring-projects-issues spring-projects-issues added type: enhancement in: mapping labels Dec 30, 2020
@spring-projects-issues spring-projects-issues added this to the 2.2 M1 (Moore) milestone Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
in: mapping type: enhancement
None yet

No branches or pull requests

2 participants