Skip to content

Commit

Permalink
fix: synchronize cache maps in SpringLookupInitializer (#17668)
Browse files Browse the repository at this point in the history
To avoid possibility to get ConcurrentModificationException.
  • Loading branch information
tltv committed Sep 21, 2023
1 parent 06bacb3 commit c2b41f1
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiFunction;
Expand Down Expand Up @@ -71,8 +72,9 @@ private SpringLookup(WebApplicationContext context,
Map<Class<?>, Collection<Class<?>>> services) {
super(services, factory);
this.context = context;
this.cachedServices = new HashMap<>();
this.cacheableServices = new HashMap<>();
this.cachedServices = Collections.synchronizedMap(new HashMap<>());
this.cacheableServices = Collections
.synchronizedMap(new HashMap<>());
}

private <T> boolean isCacheableService(Class<T> serviceClass) {
Expand Down

0 comments on commit c2b41f1

Please sign in to comment.