DATACMNS-831 - AbstractMappingContext.addPersistentEntity(…) now acquires necessary read lock.

The lookup for already available PersistentEntity instances now acquires a read lock to shield the execution from partially equipped PersistentEntity instances currently in creation from another thread.

Original pull request: #157.
This commit is contained in:
Mikael Klamra
2016-03-23 17:02:09 +01:00
committed by Oliver Gierke
parent 1bedfe4f4a
commit 046f0408d1

View File

@@ -288,11 +288,16 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
* @return
*/
protected E addPersistentEntity(TypeInformation<?> typeInformation) {
try {
read.lock();
E persistentEntity = persistentEntities.get(typeInformation);
E persistentEntity = persistentEntities.get(typeInformation);
if (persistentEntity != null) {
return persistentEntity;
if (persistentEntity != null) {
return persistentEntity;
}
} finally {
read.unlock();
}
Class<?> type = typeInformation.getType();