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

Infinite loop in unsynchronized HashMap in CrudMethodMetadataPostProcessor [DATAJPA-620] #1003

Closed
spring-projects-issues opened this issue Oct 29, 2014 · 1 comment
Assignees
Labels
type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Oct 29, 2014

Henning Sudbrock opened DATAJPA-620 and commented

The method org.springframework.data.jpa.repository.support.CrudMethodMetadataPostProcessor.CrudMethodMetadataPopulatingMethodIntercceptor#invoke is not thread-safe, although it is called concurrently when Spring-Data-JPA-Queries are executed concurrently.

More concretely, since the method uses the non-thread-safe java.util.HashMap, concurrent calls to this method may result in an infinite loop when executing the Hashmap-Lookup 'metadataCache.get(method)' (line 101 in version 1.7.0.RELEASE), and I have actually encountered this behavior in an application. (Infinite loops in concurrently used hashmaps appear to be a known problem, see, e.g., https://jira.spring.io/browse/DATACMNS-518 or http://mailinator.blogspot.dk/2009/06/beautiful-race-condition.html.)

I therefore believe that this method should be made thread-safe, e.g., by using a java.util.concurrent.ConcurrentHashMap


Affects: 1.7 GA (Evans)

Referenced from: pull request #111, and commits 532adb1, 99a35c4, 7210a5c

Backported to: 1.7.1 (Evans SR1), 1.6.5 (Dijkstra SR5)

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Oct 30, 2014

Thomas Darimont commented

I replaced the HM with a CHM, please revise

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

No branches or pull requests

2 participants