Skip to content

DATACMNS-1210 - Fix concurrency issue in BasicPersitentEntity. #259

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

Closed
wants to merge 2 commits into from

Conversation

christophstrobl
Copy link
Member

Make sure to use concurrent collection implementations for properties holding mutable state. Especially the ones making use of computeIfAbsent().

Usage of ConcurrentReferenceHashMap allows us to move on without additional changes as it allows to store null values, whereas ConcurrentHashMap would require us to store explicit NullValue placeholders for such cases, potentially causing trouble in downstream store specific projects.

JMH Benchmarks (for the mapping layer in Spring Data MongoDB) comparing ConcurrentReferenceHashMap and ConcurrentHashMap did not show any significant difference between the two.

Make sure to use concurrent collection implementations for properties holding mutable state. Especially the ones making use of computeIfAbsent().

Usage of ConcurrentReferenceHashMap allows us to move on without additional changes as it allows to store null values, whereas ConcurrentHashMap would require us to store explicit NullValue placeholders for such cases, potentially causing trouble in downstream store specific projects.

JMH Benchmarks done with the Spring Data MongoDB mapping layer showed a potential performance loss of up to 5%. However a comparison between ConcurrentReferenceHashMap and ConcurrentHashMap did not show any significant difference in performance.
Copy link
Member

@odrotbohm odrotbohm left a comment

Choose a reason for hiding this comment

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

Generally looks good to me and I am already in the process of merging. The only thing I'd like to get rid off is the JDK 9 assumption in the test case. See my line comment.

@Test // DATACMNS-1210
public void findAnnotationShouldBeThreadSafe() throws InterruptedException {

assumeTrue("Requires Java 9",
Copy link
Member

Choose a reason for hiding this comment

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

What's the reason we have to assume Java 9 here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I can remove it - the point was that the test would pass on Java8 regardless of the changes made.

Copy link
Member

Choose a reason for hiding this comment

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

Okay, I'll just go ahead and remove it during the merge.

odrotbohm pushed a commit that referenced this pull request Nov 14, 2017
Make sure to use concurrent collection implementations for properties holding mutable state. Especially the ones making use of computeIfAbsent(…).

Usage of ConcurrentReferenceHashMap allows us to move on without additional changes as it allows to store null values, whereas ConcurrentHashMap would require us to store explicit NullValue placeholders for such cases, potentially causing trouble in downstream store specific projects.

JMH Benchmarks done with the Spring Data MongoDB mapping layer showed a potential performance loss of up to 5%. However a comparison between ConcurrentReferenceHashMap and ConcurrentHashMap did not show any significant difference in performance.

Original pull request: #259.
odrotbohm added a commit that referenced this pull request Nov 14, 2017
More fixes of imports. Removed obsolete generics in constructor expressions. Removed a couple of compiler warnings in test cases. Removed assumption for test case to only run on JDK 9.

Original pull request: #259.
@odrotbohm odrotbohm closed this Nov 14, 2017
@odrotbohm odrotbohm deleted the issue/DATACMNS-1210 branch November 14, 2017 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants