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
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.springframework.core;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -39,9 +38,9 @@ public abstract class DecoratingClassLoader extends ClassLoader {
|
||||
}
|
||||
|
||||
|
||||
private final Set<String> excludedPackages = Collections.newSetFromMap(new ConcurrentHashMap<>(8));
|
||||
private final Set<String> excludedPackages = ConcurrentHashMap.newKeySet(8);
|
||||
|
||||
private final Set<String> excludedClasses = Collections.newSetFromMap(new ConcurrentHashMap<>(8));
|
||||
private final Set<String> excludedClasses = ConcurrentHashMap.newKeySet(8);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.core.task;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -183,7 +182,7 @@ public class SimpleAsyncTaskExecutor extends CustomizableThreadCreator
|
||||
public void setTaskTerminationTimeout(long timeout) {
|
||||
Assert.isTrue(timeout >= 0, "Timeout value must be >=0");
|
||||
this.taskTerminationTimeout = timeout;
|
||||
this.activeThreads = (timeout > 0 ? Collections.newSetFromMap(new ConcurrentHashMap<>()) : null);
|
||||
this.activeThreads = (timeout > 0 ? ConcurrentHashMap.newKeySet() : null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user