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

ConcurrencyModificationException in EntityCallbackDiscoverer caused by concurrent cachedEntityCallbacks modification [DATACMNS-1735]

Closed
spring-projects-issues opened this issue May 27, 2020 · 3 comments
Assignees
Labels
in: mapping type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented May 27, 2020

MyeongHyeonLee opened DATACMNS-1735 and commented

Occasionally ConcurrentModificationException occurs.

 

Caused by: java.util.ConcurrentModificationException: nullCaused by: java.util.ConcurrentModificationException: null at java.base/java.util.ArrayList.sort(ArrayList.java:1751) at org.springframework.core.annotation.AnnotationAwareOrderComparator.sort(AnnotationAwareOrderComparator.java:111) at org.springframework.data.mapping.callback.EntityCallbackDiscoverer$CallbackRetriever.getEntityCallbacks(EntityCallbackDiscoverer.java:388) at org.springframework.data.mapping.callback.EntityCallbackDiscoverer.getEntityCallbacks(EntityCallbackDiscoverer.java:142) at org.springframework.data.mapping.callback.DefaultEntityCallbacks.callback(DefaultEntityCallbacks.java:83) at org.springframework.data.jdbc.core.JdbcAggregateTemplate.triggerBeforeSave(JdbcAggregateTemplate.java:414) at org.springframework.data.jdbc.core.JdbcAggregateTemplate.store(JdbcAggregateTemplate.java:335) at org.springframework.data.jdbc.core.JdbcAggregateTemplate.update(JdbcAggregateTemplate.java:183)

 

In a concurrency situation, I think it's a clear() and sort() conflict below.

if (cachedEntityCallbacks.size() != entityCallbacks.size()) {
   cachedEntityCallbacks.clear();
   cachedEntityCallbacks.addAll(entityCallbacks);
   AnnotationAwareOrderComparator.sort(cachedEntityCallbacks);
}

It seems necessary to defend against concurrency situations.

 


Affects: 2.3 GA (Neumann)

Referenced from: pull request #446

Backported to: 2.3.1 (Neumann SR1)

@spring-projects-issues
Copy link
Author

spring-projects-issues commented May 27, 2020

Mark Paluch commented

Thanks for reporting the issue. That's an oversight on our end which was introduced with the optimization DATACMNS-1698

@spring-projects-issues
Copy link
Author

spring-projects-issues commented May 27, 2020

Mark Paluch commented

That's merged now and snapshot artifacts are deployed to repo.spring.io. Care to test against spring-data-commons-2.3.1.BUILD-SNAPSHOT?

@spring-projects-issues
Copy link
Author

spring-projects-issues commented May 27, 2020

MyeongHyeonLee commented

Mark Paluch

In my application I passed all tests with 2.3.1.BUILD-SNAPSHOT.

There was no problem with the service.

 

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mapping type: bug
Projects
None yet
Development

No branches or pull requests

2 participants