Skip to content

Commit 8ebd5a7

Browse files
committed
HHH-18632 Concurrency issue with AbstractEntityPersister#nonLazyPropertyLoadPlansByName
1 parent ec50213 commit 8ebd5a7

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ public abstract class AbstractEntityPersister
464464
private final boolean implementsLifecycle;
465465

466466
private List<UniqueKeyEntry> uniqueKeyEntries = null; //lazily initialized
467-
private HashMap<String,SingleIdArrayLoadPlan> nonLazyPropertyLoadPlansByName;
467+
private ConcurrentHashMap<String,SingleIdArrayLoadPlan> nonLazyPropertyLoadPlansByName;
468468

469469
public AbstractEntityPersister(
470470
final PersistentClass persistentClass,
@@ -1548,17 +1548,17 @@ protected Object initializeLazyPropertiesFromDatastore(
15481548
int propertyIndex = getPropertyIndex( fieldName );
15491549
partsToSelect.add( getAttributeMapping( propertyIndex ) );
15501550
SingleIdArrayLoadPlan lazyLoanPlan;
1551-
if ( nonLazyPropertyLoadPlansByName == null ) {
1552-
nonLazyPropertyLoadPlansByName = new HashMap<>();
1551+
ConcurrentHashMap<String, SingleIdArrayLoadPlan> propertyLoadPlansByName = this.nonLazyPropertyLoadPlansByName;
1552+
if ( propertyLoadPlansByName == null ) {
1553+
propertyLoadPlansByName = new ConcurrentHashMap<>();
15531554
lazyLoanPlan = createLazyLoanPlan( partsToSelect );
1554-
;
1555-
nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan );
1555+
propertyLoadPlansByName.put( fieldName, lazyLoanPlan );
1556+
this.nonLazyPropertyLoadPlansByName = propertyLoadPlansByName;
15561557
}
15571558
else {
15581559
lazyLoanPlan = nonLazyPropertyLoadPlansByName.get( fieldName );
15591560
if ( lazyLoanPlan == null ) {
15601561
lazyLoanPlan = createLazyLoanPlan( partsToSelect );
1561-
;
15621562
nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan );
15631563
}
15641564
}

0 commit comments

Comments
 (0)