Skip to content

Commit 73103f3

Browse files
committed
DATACMNS-1281 - Fixed potential concurrency issue in MappingAuditableBeanWrapperFactory.
We now use a ConcurrentReferenceHashMap to cache the metadata calculated to prevent ConcurrentModificationExceptions getBeanWrapperFor(…).
1 parent ac63f08 commit 73103f3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/main/java/org/springframework/data/auditing/MappingAuditableBeanWrapperFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
package org.springframework.data.auditing;
1717

1818
import java.time.temporal.TemporalAccessor;
19-
import java.util.HashMap;
2019
import java.util.Map;
2120
import java.util.Optional;
2221

@@ -32,6 +31,7 @@
3231
import org.springframework.data.mapping.context.PersistentEntities;
3332
import org.springframework.data.util.Optionals;
3433
import org.springframework.util.Assert;
34+
import org.springframework.util.ConcurrentReferenceHashMap;
3535

3636
/**
3737
* {@link AuditableBeanWrapperFactory} that will create am {@link AuditableBeanWrapper} using mapping information
@@ -57,7 +57,7 @@ public MappingAuditableBeanWrapperFactory(PersistentEntities entities) {
5757
Assert.notNull(entities, "PersistentEntities must not be null!");
5858

5959
this.entities = entities;
60-
this.metadataCache = new HashMap<>();
60+
this.metadataCache = new ConcurrentReferenceHashMap<>();
6161
}
6262

6363
/*

0 commit comments

Comments
 (0)