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

Prevent thread from being blocked by JDK-8 ConcurrentHashMap#computeIfAbsent() #2223

Merged
merged 1 commit into from Apr 9, 2021

Conversation

harawata
Copy link
Member

@harawata harawata commented Apr 9, 2021

This is a workaround for JDK-8161372.

Related to ...

We should drop this workaround once we drop Java 8 support (or the fix is backported).

…fAbsent()

This is a workaround for JDK-8161372

mybatis#1929
https://groups.google.com/g/mybatis-user/c/iBTN98c0dP4/m/H6IJS-LzAQAJ

We should drop this workaround once we drop Java 8 support or the fix is backported.
@harawata harawata added the bug on dependency library Indicates a bug on dependency library label Apr 9, 2021
@harawata harawata added this to the 3.5.7 milestone Apr 9, 2021
@harawata harawata self-assigned this Apr 9, 2021
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.008%) to 87.248% when pulling 2fc8ec0 on harawata:workaround-jdk-8161372 into f6caf12 on mybatis:master.

@harawata harawata merged commit 0262a99 into mybatis:master Apr 9, 2021
if (value != null) {
return value;
}
return map.computeIfAbsent(key, mappingFunction::apply);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use mappingFunction ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ComputeIfAbsent blocks when multiple threads obtain the same key. I think it's to improve performance. https://bugs.openjdk.java.net/browse/JDK-8161372

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug on dependency library Indicates a bug on dependency library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants