Skip to content

Commit 307fb20

Browse files
committed
HHH-18632 Concurrency issue with AbstractEntityPersister#nonLazyPropertyLoadPlansByName
1 parent 0f0f50d commit 307fb20

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
@@ -496,7 +496,7 @@ public abstract class AbstractEntityPersister
496496
private final boolean implementsLifecycle;
497497

498498
private List<UniqueKeyEntry> uniqueKeyEntries = null; //lazily initialized
499-
private HashMap<String,SingleIdArrayLoadPlan> nonLazyPropertyLoadPlansByName;
499+
private ConcurrentHashMap<String,SingleIdArrayLoadPlan> nonLazyPropertyLoadPlansByName;
500500

501501
@Deprecated(since = "6.0")
502502
public AbstractEntityPersister(
@@ -1671,17 +1671,17 @@ protected Object initializeLazyPropertiesFromDatastore(
16711671
int propertyIndex = getPropertyIndex( fieldName );
16721672
partsToSelect.add( getAttributeMapping( propertyIndex ) );
16731673
SingleIdArrayLoadPlan lazyLoanPlan;
1674-
if ( nonLazyPropertyLoadPlansByName == null ) {
1675-
nonLazyPropertyLoadPlansByName = new HashMap<>();
1674+
ConcurrentHashMap<String, SingleIdArrayLoadPlan> propertyLoadPlansByName = this.nonLazyPropertyLoadPlansByName;
1675+
if ( propertyLoadPlansByName == null ) {
1676+
propertyLoadPlansByName = new ConcurrentHashMap<>();
16761677
lazyLoanPlan = createLazyLoanPlan( partsToSelect );
1677-
;
1678-
nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan );
1678+
propertyLoadPlansByName.put( fieldName, lazyLoanPlan );
1679+
this.nonLazyPropertyLoadPlansByName = propertyLoadPlansByName;
16791680
}
16801681
else {
16811682
lazyLoanPlan = nonLazyPropertyLoadPlansByName.get( fieldName );
16821683
if ( lazyLoanPlan == null ) {
16831684
lazyLoanPlan = createLazyLoanPlan( partsToSelect );
1684-
;
16851685
nonLazyPropertyLoadPlansByName.put( fieldName, lazyLoanPlan );
16861686
}
16871687
}

0 commit comments

Comments
 (0)