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:
Oliver Gierke
2013-11-04 10:35:19 +01:00
parent 057c2e9bf8
commit d26f90b281
2 changed files with 21 additions and 1 deletions

View File

@@ -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();
}