Skip to content

Commit c2b41f1

Browse files
authored
fix: synchronize cache maps in SpringLookupInitializer (#17668)
To avoid possibility to get ConcurrentModificationException.
1 parent 06bacb3 commit c2b41f1

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

vaadin-spring/src/main/java/com/vaadin/flow/spring/SpringLookupInitializer.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import java.util.ArrayList;
2222
import java.util.Collection;
23+
import java.util.Collections;
2324
import java.util.HashMap;
2425
import java.util.Map;
2526
import java.util.function.BiFunction;
@@ -71,8 +72,9 @@ private SpringLookup(WebApplicationContext context,
7172
Map<Class<?>, Collection<Class<?>>> services) {
7273
super(services, factory);
7374
this.context = context;
74-
this.cachedServices = new HashMap<>();
75-
this.cacheableServices = new HashMap<>();
75+
this.cachedServices = Collections.synchronizedMap(new HashMap<>());
76+
this.cacheableServices = Collections
77+
.synchronizedMap(new HashMap<>());
7678
}
7779

7880
private <T> boolean isCacheableService(Class<T> serviceClass) {

0 commit comments

Comments
 (0)