Use ConcurrentHashMap.newKeySet
In places where a ConcurrentHashMap was used as a set by wrapping it with Collections.newSetFromMap, switch to just using the set returned by ConcurrentHashMap.newKeySet directly. Closes gh-32294
This commit is contained in:
committed by
Sam Brannen
parent
ff9c7141c5
commit
f9fe8efb2e
@@ -18,7 +18,6 @@ package org.springframework.context.event;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -82,7 +81,7 @@ public class EventListenerMethodProcessor
|
||||
@Nullable
|
||||
private final EventExpressionEvaluator evaluator;
|
||||
|
||||
private final Set<Class<?>> nonAnnotatedClasses = Collections.newSetFromMap(new ConcurrentHashMap<>(64));
|
||||
private final Set<Class<?>> nonAnnotatedClasses = ConcurrentHashMap.newKeySet(64);
|
||||
|
||||
|
||||
public EventListenerMethodProcessor() {
|
||||
|
||||
@@ -229,7 +229,7 @@ public class DefaultLifecycleProcessor implements LifecycleProcessor, BeanFactor
|
||||
|
||||
void stopForRestart() {
|
||||
if (this.running) {
|
||||
this.stoppedBeans = Collections.newSetFromMap(new ConcurrentHashMap<>());
|
||||
this.stoppedBeans = ConcurrentHashMap.newKeySet();
|
||||
stopBeans();
|
||||
this.running = false;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.lang.reflect.Method;
|
||||
import java.time.Duration;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
@@ -149,7 +148,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
@Nullable
|
||||
private TaskSchedulerRouter localScheduler;
|
||||
|
||||
private final Set<Class<?>> nonAnnotatedClasses = Collections.newSetFromMap(new ConcurrentHashMap<>(64));
|
||||
private final Set<Class<?>> nonAnnotatedClasses = ConcurrentHashMap.newKeySet(64);
|
||||
|
||||
private final Map<Object, Set<ScheduledTask>> scheduledTasks = new IdentityHashMap<>(16);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user