DATACMNS-362 - Resolved concurrency problem in Repositories.
We now create a copy of the keys before iterating over them in Repositories.getRepoInforFor(…) to make sure other threads can safely trigger lookupRepositoryFactoryInformationFor(…) which potentially alters the repositories instance variable. So far we haven't guarded against this scenario which caused a ConcurrentModificationException.
This commit is contained in:
@@ -173,7 +173,10 @@ public class Repositories implements Iterable<Class<?>> {
|
||||
|
||||
Assert.notNull(domainClass);
|
||||
|
||||
for (RepositoryFactoryInformation<Object, Serializable> information : repositories.keySet()) {
|
||||
// Create defensive copy of the keys to allow threads to potentially add values while iterating over them
|
||||
Set<RepositoryFactoryInformation<Object, Serializable>> keys = Collections.unmodifiableSet(repositories.keySet());
|
||||
|
||||
for (RepositoryFactoryInformation<Object, Serializable> information : keys) {
|
||||
if (domainClass.equals(information.getEntityInformation().getJavaType())) {
|
||||
return information;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user