Use Map.computeIfAbsent() where feasible
See gh-31916
This commit is contained in:
committed by
Stéphane Nicoll
parent
adcf236a3d
commit
ea5ef098cf
@@ -102,11 +102,7 @@ public class SpringConfigurator extends Configurator {
|
||||
private String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
|
||||
String wacId = wac.getId();
|
||||
|
||||
Map<Class<?>, String> beanNamesByType = cache.get(wacId);
|
||||
if (beanNamesByType == null) {
|
||||
beanNamesByType = new ConcurrentHashMap<>();
|
||||
cache.put(wacId, beanNamesByType);
|
||||
}
|
||||
Map<Class<?>, String> beanNamesByType = cache.computeIfAbsent(wacId, k -> new ConcurrentHashMap<>());
|
||||
|
||||
if (!beanNamesByType.containsKey(endpointClass)) {
|
||||
String[] names = wac.getBeanNamesForType(endpointClass);
|
||||
|
||||
Reference in New Issue
Block a user