Skip to content

Commit

Permalink
DATACMNS-1281 - Fixed potential concurrency issue in MappingAuditable…
Browse files Browse the repository at this point in the history
…BeanWrapperFactory.

We now use a ConcurrentReferenceHashMap to cache the metadata calculated to prevent ConcurrentModificationExceptions getBeanWrapperFor(…).
  • Loading branch information
odrotbohm committed Mar 27, 2018
1 parent 3527f19 commit 8bbcca2
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.springframework.data.auditing;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import org.springframework.data.annotation.CreatedBy;
Expand All @@ -30,6 +29,7 @@
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.mapping.context.PersistentEntities;
import org.springframework.util.Assert;
import org.springframework.util.ConcurrentReferenceHashMap;

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

this.entities = entities;
this.metadataCache = new HashMap<Class<?>, MappingAuditingMetadata>();
this.metadataCache = new ConcurrentReferenceHashMap<Class<?>, MappingAuditingMetadata>();
}

/*
Expand Down

0 comments on commit 8bbcca2

Please # to comment.