-
Notifications
You must be signed in to change notification settings - Fork 683
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
Conversation
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.
There was a problem hiding this 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", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.
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.
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 storenull
values, whereasConcurrentHashMap
would require us to store explicitNullValue
placeholders for such cases, potentially causing trouble in downstream store specific projects.JMH Benchmarks (for the mapping layer in Spring Data MongoDB) comparing
ConcurrentReferenceHashMap
andConcurrentHashMap
did not show any significant difference between the two.