HHH-18475 fix race condition in AbstractRowMapper
This commit is contained in:
parent
30241bbe9f
commit
fbdec58da2
|
@ -50,7 +50,7 @@ public abstract class AbstractRowReader implements RowReader {
|
||||||
|
|
||||||
// cache map for looking up EntityReferenceInitializer by EntityReference to help with resolving
|
// cache map for looking up EntityReferenceInitializer by EntityReference to help with resolving
|
||||||
// bidirectional EntityReference and fetches.
|
// bidirectional EntityReference and fetches.
|
||||||
private Map<EntityReference,EntityReferenceInitializer> entityInitializerByEntityReference;
|
private volatile Map<EntityReference,EntityReferenceInitializer> entityInitializerByEntityReference;
|
||||||
|
|
||||||
public AbstractRowReader(ReaderCollector readerCollector) {
|
public AbstractRowReader(ReaderCollector readerCollector) {
|
||||||
this.entityReferenceInitializers = readerCollector.getEntityReferenceInitializers().toArray( EMPTY_REFERENCE_INITIALIZERS );
|
this.entityReferenceInitializers = readerCollector.getEntityReferenceInitializers().toArray( EMPTY_REFERENCE_INITIALIZERS );
|
||||||
|
@ -149,13 +149,14 @@ public abstract class AbstractRowReader implements RowReader {
|
||||||
|
|
||||||
private EntityReferenceInitializer getInitializerByEntityReference(EntityReference targetEntityReference) {
|
private EntityReferenceInitializer getInitializerByEntityReference(EntityReference targetEntityReference) {
|
||||||
if ( entityInitializerByEntityReference == null ) {
|
if ( entityInitializerByEntityReference == null ) {
|
||||||
entityInitializerByEntityReference = new HashMap<>( entityReferenceInitializers.length );
|
Map<EntityReference,EntityReferenceInitializer> entityInitializerByEntityReference = new HashMap<>( entityReferenceInitializers.length );
|
||||||
for ( EntityReferenceInitializer entityReferenceInitializer : entityReferenceInitializers ) {
|
for ( EntityReferenceInitializer entityReferenceInitializer : entityReferenceInitializers ) {
|
||||||
entityInitializerByEntityReference.put(
|
entityInitializerByEntityReference.put(
|
||||||
entityReferenceInitializer.getEntityReference(),
|
entityReferenceInitializer.getEntityReference(),
|
||||||
entityReferenceInitializer
|
entityReferenceInitializer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
this.entityInitializerByEntityReference = entityInitializerByEntityReference;
|
||||||
}
|
}
|
||||||
return entityInitializerByEntityReference.get(
|
return entityInitializerByEntityReference.get(
|
||||||
targetEntityReference
|
targetEntityReference
|
||||||
|
|
Loading…
Reference in New Issue