DATACMNS-390 - Create defensive copy for persistent entities in AbstractMappingContext.
To prevent ConcurrentModificationExceptions when iterating over PersistentEntities while further entity types are potentially added to the MappingContext we now return a immutable defensive copy of the current entity set.
This commit is contained in:
@@ -124,7 +124,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
|
||||
public Collection<E> getPersistentEntities() {
|
||||
try {
|
||||
read.lock();
|
||||
return persistentEntities.values();
|
||||
return Collections.unmodifiableSet(new HashSet<E>(persistentEntities.values()));
|
||||
} finally {
|
||||
read.unlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user