DATACMNS-1735 - Fix ConcurrencyModificationException in EntityCallbackDiscoverer.

We now guard modifications of the cached entity callbacks list with a synchronization block.

Original pull request: #446.
This commit is contained in:
mhyeon-lee
2020-05-27 15:10:25 +09:00
committed by Mark Paluch
parent ce7928b28b
commit d9969cb7d4
2 changed files with 46 additions and 3 deletions

View File

@@ -44,6 +44,7 @@ import org.springframework.util.comparator.Comparators;
/**
* @author Mark Paluch
* @author Christoph Strobl
* @author Myeonghyeon Lee
* @since 2.2
*/
class EntityCallbackDiscoverer {
@@ -383,9 +384,13 @@ class EntityCallbackDiscoverer {
if (this.entityCallbackBeans.isEmpty()) {
if (cachedEntityCallbacks.size() != entityCallbacks.size()) {
cachedEntityCallbacks.clear();
cachedEntityCallbacks.addAll(entityCallbacks);
AnnotationAwareOrderComparator.sort(cachedEntityCallbacks);
List<EntityCallback<?>> entityCallbacks = new ArrayList<>(this.entityCallbacks.size());
AnnotationAwareOrderComparator.sort(entityCallbacks);
synchronized(this) {
cachedEntityCallbacks.clear();
cachedEntityCallbacks.addAll(entityCallbacks);
}
}
return cachedEntityCallbacks;