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
spring-projects-issues commentedOct 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)
The text was updated successfully, but these errors were encountered: