Polishing
This commit is contained in:
parent
667851c0fa
commit
07c0213f20
|
|
@ -582,7 +582,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
|||
public void registerContainedBean(String containedBeanName, String containingBeanName) {
|
||||
synchronized (this.containedBeanMap) {
|
||||
Set<String> containedBeans =
|
||||
this.containedBeanMap.computeIfAbsent(containingBeanName, k -> new LinkedHashSet<>(8));
|
||||
this.containedBeanMap.computeIfAbsent(containingBeanName, key -> new LinkedHashSet<>(8));
|
||||
if (!containedBeans.add(containedBeanName)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -601,7 +601,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
|||
|
||||
synchronized (this.dependentBeanMap) {
|
||||
Set<String> dependentBeans =
|
||||
this.dependentBeanMap.computeIfAbsent(canonicalName, k -> new LinkedHashSet<>(8));
|
||||
this.dependentBeanMap.computeIfAbsent(canonicalName, key -> new LinkedHashSet<>(8));
|
||||
if (!dependentBeans.add(dependentBeanName)) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -609,7 +609,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
|
|||
|
||||
synchronized (this.dependenciesForBeanMap) {
|
||||
Set<String> dependenciesForBean =
|
||||
this.dependenciesForBeanMap.computeIfAbsent(dependentBeanName, k -> new LinkedHashSet<>(8));
|
||||
this.dependenciesForBeanMap.computeIfAbsent(dependentBeanName, key -> new LinkedHashSet<>(8));
|
||||
dependenciesForBean.add(canonicalName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
|||
builder.setUnless(getAttributeValue(opElement, "unless", ""));
|
||||
builder.setSync(Boolean.parseBoolean(getAttributeValue(opElement, "sync", "false")));
|
||||
|
||||
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2));
|
||||
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, key -> new ArrayList<>(2));
|
||||
col.add(builder.build());
|
||||
}
|
||||
|
||||
|
|
@ -136,7 +136,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
|||
builder.setBeforeInvocation(Boolean.parseBoolean(after.trim()));
|
||||
}
|
||||
|
||||
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2));
|
||||
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, key -> new ArrayList<>(2));
|
||||
col.add(builder.build());
|
||||
}
|
||||
|
||||
|
|
@ -150,7 +150,7 @@ class CacheAdviceParser extends AbstractSingleBeanDefinitionParser {
|
|||
parserContext.getReaderContext(), new CachePutOperation.Builder());
|
||||
builder.setUnless(getAttributeValue(opElement, "unless", ""));
|
||||
|
||||
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, k -> new ArrayList<>(2));
|
||||
Collection<CacheOperation> col = cacheOpMap.computeIfAbsent(nameHolder, key -> new ArrayList<>(2));
|
||||
col.add(builder.build());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -377,7 +377,7 @@ public class ScheduledAnnotationBeanPostProcessor
|
|||
try {
|
||||
task = ScheduledAnnotationReactiveSupport.createSubscriptionRunnable(method, bean, scheduled,
|
||||
this.registrar::getObservationRegistry,
|
||||
this.reactiveSubscriptions.computeIfAbsent(bean, k -> new CopyOnWriteArrayList<>()));
|
||||
this.reactiveSubscriptions.computeIfAbsent(bean, key -> new CopyOnWriteArrayList<>()));
|
||||
}
|
||||
catch (IllegalArgumentException ex) {
|
||||
throw new IllegalStateException("Could not create recurring task for @Scheduled method '" +
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ public class CustomizerRegistry {
|
|||
Class<? extends KeyFactoryCustomizer> klass = customizer.getClass();
|
||||
for (Class type : customizerTypes) {
|
||||
if (type.isAssignableFrom(klass)) {
|
||||
List<KeyFactoryCustomizer> list = customizers.computeIfAbsent(type, k -> new ArrayList<>());
|
||||
List<KeyFactoryCustomizer> list = customizers.computeIfAbsent(type, key -> new ArrayList<>());
|
||||
list.add(customizer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,9 +88,7 @@ final class AnnotationTypeMapping {
|
|||
this.root = (source != null ? source.getRoot() : this);
|
||||
this.distance = (source == null ? 0 : source.getDistance() + 1);
|
||||
this.annotationType = annotationType;
|
||||
this.metaTypes = merge(
|
||||
source != null ? source.getMetaTypes() : null,
|
||||
annotationType);
|
||||
this.metaTypes = merge((source != null ? source.getMetaTypes() : null), annotationType);
|
||||
this.annotation = annotation;
|
||||
this.attributes = AttributeMethods.forAnnotationType(annotationType);
|
||||
this.mirrorSets = new MirrorSets();
|
||||
|
|
|
|||
|
|
@ -885,8 +885,7 @@ public abstract class AnnotationUtils {
|
|||
private static Map<String, DefaultValueHolder> getDefaultValues(
|
||||
Class<? extends Annotation> annotationType) {
|
||||
|
||||
return defaultValuesCache.computeIfAbsent(annotationType,
|
||||
AnnotationUtils::computeDefaultValues);
|
||||
return defaultValuesCache.computeIfAbsent(annotationType, AnnotationUtils::computeDefaultValues);
|
||||
}
|
||||
|
||||
private static Map<String, DefaultValueHolder> computeDefaultValues(
|
||||
|
|
|
|||
|
|
@ -481,7 +481,7 @@ public class GenericConversionService implements ConfigurableConversionService {
|
|||
}
|
||||
|
||||
private ConvertersForPair getMatchableConverters(ConvertiblePair convertiblePair) {
|
||||
return this.converters.computeIfAbsent(convertiblePair, k -> new ConvertersForPair());
|
||||
return this.converters.computeIfAbsent(convertiblePair, key -> new ConvertersForPair());
|
||||
}
|
||||
|
||||
public void remove(Class<?> sourceType, Class<?> targetType) {
|
||||
|
|
|
|||
|
|
@ -321,8 +321,8 @@ public class SpringFactoriesLoader {
|
|||
SpringFactoriesLoader.class.getClassLoader());
|
||||
Map<String, Factories> factoriesCache = cache.computeIfAbsent(
|
||||
resourceClassLoader, key -> new ConcurrentReferenceHashMap<>());
|
||||
Factories factories = factoriesCache.computeIfAbsent(resourceLocation, key ->
|
||||
new Factories(loadFactoriesResource(resourceClassLoader, resourceLocation)));
|
||||
Factories factories = factoriesCache.computeIfAbsent(resourceLocation,
|
||||
key -> new Factories(loadFactoriesResource(resourceClassLoader, resourceLocation)));
|
||||
return new SpringFactoriesLoader(classLoader, factories.byType());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ public class SimpleNamespaceContext implements NamespaceContext {
|
|||
else {
|
||||
this.prefixToNamespaceUri.put(prefix, namespaceUri);
|
||||
Set<String> prefixes =
|
||||
this.namespaceUriToPrefixes.computeIfAbsent(namespaceUri, k -> new LinkedHashSet<>());
|
||||
this.namespaceUriToPrefixes.computeIfAbsent(namespaceUri, key -> new LinkedHashSet<>());
|
||||
prefixes.add(prefix);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
|||
return null;
|
||||
}
|
||||
|
||||
Deque<Session> sessionList = this.cachedSessions.computeIfAbsent(mode, k -> new ArrayDeque<>());
|
||||
Deque<Session> sessionList = this.cachedSessions.computeIfAbsent(mode, key -> new ArrayDeque<>());
|
||||
Session session = null;
|
||||
synchronized (sessionList) {
|
||||
if (!sessionList.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ public class JmsResourceHolder extends ResourceHolderSupport {
|
|||
this.sessions.add(session);
|
||||
if (connection != null) {
|
||||
Deque<Session> sessions =
|
||||
this.sessionsPerConnection.computeIfAbsent(connection, k -> new ArrayDeque<>());
|
||||
this.sessionsPerConnection.computeIfAbsent(connection, key -> new ArrayDeque<>());
|
||||
sessions.add(session);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -434,13 +434,13 @@ public class StompHeaders implements MultiValueMap<String, String>, Serializable
|
|||
*/
|
||||
@Override
|
||||
public void add(String headerName, @Nullable String headerValue) {
|
||||
List<String> headerValues = this.headers.computeIfAbsent(headerName, k -> new ArrayList<>(1));
|
||||
List<String> headerValues = this.headers.computeIfAbsent(headerName, key -> new ArrayList<>(1));
|
||||
headerValues.add(headerValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAll(String headerName, List<? extends String> headerValues) {
|
||||
List<String> currentValues = this.headers.computeIfAbsent(headerName, k -> new ArrayList<>(1));
|
||||
List<String> currentValues = this.headers.computeIfAbsent(headerName, key -> new ArrayList<>(1));
|
||||
currentValues.addAll(headerValues);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -247,7 +247,7 @@ public class NativeMessageHeaderAccessor extends MessageHeaderAccessor {
|
|||
nativeHeaders = new LinkedMultiValueMap<>(3);
|
||||
setHeader(NATIVE_HEADERS, nativeHeaders);
|
||||
}
|
||||
List<String> values = nativeHeaders.computeIfAbsent(name, k -> new ArrayList<>(1));
|
||||
List<String> values = nativeHeaders.computeIfAbsent(name, key -> new ArrayList<>(1));
|
||||
values.add(value);
|
||||
setModified(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ public class DefaultContextCache implements ContextCache {
|
|||
}
|
||||
|
||||
private Set<Class<?>> getActiveTestClasses(MergedContextConfiguration mergedConfig) {
|
||||
return this.contextUsageMap.computeIfAbsent(mergedConfig, mcc -> new HashSet<>());
|
||||
return this.contextUsageMap.computeIfAbsent(mergedConfig, key -> new HashSet<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ public abstract class Jackson2CodecSupport {
|
|||
this.objectMapperRegistrations = new LinkedHashMap<>();
|
||||
}
|
||||
Map<MimeType, ObjectMapper> registrations =
|
||||
this.objectMapperRegistrations.computeIfAbsent(clazz, c -> new LinkedHashMap<>());
|
||||
this.objectMapperRegistrations.computeIfAbsent(clazz, key -> new LinkedHashMap<>());
|
||||
registrar.accept(registrations);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
|||
this.objectMapperRegistrations = new LinkedHashMap<>();
|
||||
}
|
||||
Map<MediaType, ObjectMapper> registrations =
|
||||
this.objectMapperRegistrations.computeIfAbsent(clazz, c -> new LinkedHashMap<>());
|
||||
this.objectMapperRegistrations.computeIfAbsent(clazz, key -> new LinkedHashMap<>());
|
||||
registrar.accept(registrations);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
|||
|
||||
private @Nullable Map<String, Object> attributes;
|
||||
|
||||
|
||||
private @Nullable ServerHttpAsyncRequestControl asyncRequestControl;
|
||||
|
||||
|
||||
|
|
@ -377,7 +376,6 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
|||
public Iterator<String> iterator() {
|
||||
return servletRequest.getAttributeNames().asIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return AttributesMap.this.size();
|
||||
|
|
@ -401,7 +399,6 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
|||
public boolean hasNext() {
|
||||
return e.hasMoreElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object next() {
|
||||
String name = e.nextElement();
|
||||
|
|
@ -409,7 +406,6 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return AttributesMap.this.size();
|
||||
|
|
@ -433,7 +429,6 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
|||
public boolean hasNext() {
|
||||
return e.hasMoreElements();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entry<String, Object> next() {
|
||||
String name = e.nextElement();
|
||||
|
|
@ -442,7 +437,6 @@ public class ServletServerHttpRequest implements ServerHttpRequest {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return AttributesMap.this.size();
|
||||
|
|
|
|||
|
|
@ -387,7 +387,6 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest {
|
|||
@Override
|
||||
public void onError(Throwable throwable) {
|
||||
RequestBodyPublisher.this.onError(throwable);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ class ControllerMethodResolver {
|
|||
|
||||
this.initBinderMethodCache
|
||||
.computeIfAbsent(handlerType,
|
||||
clazz -> MethodIntrospector.selectMethods(handlerType, INIT_BINDER_METHODS))
|
||||
key -> MethodIntrospector.selectMethods(key, INIT_BINDER_METHODS))
|
||||
.forEach(method -> {
|
||||
Object bean = handlerMethod.getBean();
|
||||
result.add(getInitBinderMethod(bean, method));
|
||||
|
|
@ -385,7 +385,7 @@ class ControllerMethodResolver {
|
|||
|
||||
this.modelAttributeMethodCache
|
||||
.computeIfAbsent(handlerType,
|
||||
clazz -> MethodIntrospector.selectMethods(handlerType, MODEL_ATTRIBUTE_METHODS))
|
||||
key -> MethodIntrospector.selectMethods(key, MODEL_ATTRIBUTE_METHODS))
|
||||
.forEach(method -> {
|
||||
Object bean = handlerMethod.getBean();
|
||||
result.add(createAttributeMethod(bean, method));
|
||||
|
|
|
|||
|
|
@ -126,7 +126,8 @@ public class UrlFilenameViewController extends AbstractUrlViewController {
|
|||
* @see #postProcessViewName
|
||||
*/
|
||||
protected String getViewNameForUrlPath(String uri) {
|
||||
return this.viewNameCache.computeIfAbsent(uri, u -> postProcessViewName(extractViewNameFromUrlPath(u)));
|
||||
return this.viewNameCache.computeIfAbsent(uri,
|
||||
key -> postProcessViewName(extractViewNameFromUrlPath(key)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,8 +55,7 @@ public class SpringConfigurator extends Configurator {
|
|||
|
||||
private static final Log logger = LogFactory.getLog(SpringConfigurator.class);
|
||||
|
||||
private static final Map<String, Map<Class<?>, String>> cache =
|
||||
new ConcurrentHashMap<>();
|
||||
private static final Map<String, Map<Class<?>, String>> cache = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
|
@ -100,24 +99,19 @@ public class SpringConfigurator extends Configurator {
|
|||
|
||||
private @Nullable String getBeanNameByType(WebApplicationContext wac, Class<?> endpointClass) {
|
||||
String wacId = wac.getId();
|
||||
Map<Class<?>, String> beanNamesByType = cache.computeIfAbsent(wacId, key -> new ConcurrentHashMap<>());
|
||||
|
||||
Map<Class<?>, String> beanNamesByType = cache.computeIfAbsent(wacId, k -> new ConcurrentHashMap<>());
|
||||
|
||||
if (!beanNamesByType.containsKey(endpointClass)) {
|
||||
String beanName = beanNamesByType.get(endpointClass);
|
||||
if (beanName == null) {
|
||||
String[] names = wac.getBeanNamesForType(endpointClass);
|
||||
if (names.length == 1) {
|
||||
beanNamesByType.put(endpointClass, names[0]);
|
||||
}
|
||||
else {
|
||||
beanNamesByType.put(endpointClass, NO_VALUE);
|
||||
if (names.length > 1) {
|
||||
throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
|
||||
endpointClass.getName() + "]: bean names " + Arrays.toString(names));
|
||||
}
|
||||
beanName = (names.length == 1 ? names[0] : NO_VALUE);
|
||||
beanNamesByType.put(endpointClass, beanName);
|
||||
if (names.length > 1) {
|
||||
throw new IllegalStateException("Found multiple @ServerEndpoint's of type [" +
|
||||
endpointClass.getName() + "]: bean names " + Arrays.toString(names));
|
||||
}
|
||||
}
|
||||
|
||||
String beanName = beanNamesByType.get(endpointClass);
|
||||
return (NO_VALUE.equals(beanName) ? null : beanName);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue