Polishing (backported from master)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -513,7 +513,10 @@ public abstract class AbstractAutoProxyCreator extends ProxyProcessorSupport
|
||||
|
||||
List<Object> allInterceptors = new ArrayList<>();
|
||||
if (specificInterceptors != null) {
|
||||
allInterceptors.addAll(Arrays.asList(specificInterceptors));
|
||||
if (specificInterceptors.length > 0) {
|
||||
// specificInterceptors may equals PROXY_WITHOUT_ADDITIONAL_INTERCEPTORS
|
||||
allInterceptors.addAll(Arrays.asList(specificInterceptors));
|
||||
}
|
||||
if (commonInterceptors.length > 0) {
|
||||
if (this.applyCommonInterceptorsFirst) {
|
||||
allInterceptors.addAll(0, Arrays.asList(commonInterceptors));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -489,8 +489,8 @@ public class GroovyBeanDefinitionReader extends AbstractBeanDefinitionReader imp
|
||||
resolveConstructorArguments(args, 2, hasClosureArgument ? args.length - 1 : args.length);
|
||||
this.currentBeanDefinition = new GroovyBeanDefinitionWrapper(beanName, (Class<?>) args[1], constructorArgs);
|
||||
Map<?, ?> namedArgs = (Map<?, ?>) args[0];
|
||||
for (Object o : namedArgs.keySet()) {
|
||||
String propName = (String) o;
|
||||
for (Object key : namedArgs.keySet()) {
|
||||
String propName = (String) key;
|
||||
setProperty(propName, namedArgs.get(propName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -384,7 +384,7 @@ public abstract class ReflectionUtils {
|
||||
* @throws IllegalStateException if introspection fails
|
||||
*/
|
||||
public static Method[] getAllDeclaredMethods(Class<?> leafClass) {
|
||||
final List<Method> methods = new ArrayList<>(32);
|
||||
final List<Method> methods = new ArrayList<>(20);
|
||||
doWithMethods(leafClass, methods::add);
|
||||
return methods.toArray(EMPTY_METHOD_ARRAY);
|
||||
}
|
||||
@@ -410,7 +410,7 @@ public abstract class ReflectionUtils {
|
||||
* @since 5.2
|
||||
*/
|
||||
public static Method[] getUniqueDeclaredMethods(Class<?> leafClass, @Nullable MethodFilter mf) {
|
||||
final List<Method> methods = new ArrayList<>(32);
|
||||
final List<Method> methods = new ArrayList<>(20);
|
||||
doWithMethods(leafClass, method -> {
|
||||
boolean knownSignature = false;
|
||||
Method methodBeingOverriddenWithCovariantReturnType = null;
|
||||
@@ -505,12 +505,15 @@ public abstract class ReflectionUtils {
|
||||
* @see java.lang.Object#equals(Object)
|
||||
*/
|
||||
public static boolean isEqualsMethod(@Nullable Method method) {
|
||||
if (method == null || !method.getName().equals("equals")) {
|
||||
if (method == null) {
|
||||
return false;
|
||||
}
|
||||
if (method.getParameterCount() != 1) {
|
||||
return false;
|
||||
}
|
||||
if (!method.getName().equals("equals")) {
|
||||
return false;
|
||||
}
|
||||
return method.getParameterTypes()[0] == Object.class;
|
||||
}
|
||||
|
||||
@@ -519,7 +522,7 @@ public abstract class ReflectionUtils {
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
public static boolean isHashCodeMethod(@Nullable Method method) {
|
||||
return (method != null && method.getName().equals("hashCode") && method.getParameterCount() == 0);
|
||||
return method != null && method.getParameterCount() == 0 && method.getName().equals("hashCode");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -527,7 +530,7 @@ public abstract class ReflectionUtils {
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
public static boolean isToStringMethod(@Nullable Method method) {
|
||||
return (method != null && method.getName().equals("toString") && method.getParameterCount() == 0);
|
||||
return (method != null && method.getParameterCount() == 0 && method.getName().equals("toString"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -622,6 +625,7 @@ public abstract class ReflectionUtils {
|
||||
* <p>Thrown exceptions are handled via a call to {@link #handleReflectionException(Exception)}.
|
||||
* @param field the field to set
|
||||
* @param target the target object on which to set the field
|
||||
* (or {@code null} for a static field)
|
||||
* @param value the value to set (may be {@code null})
|
||||
*/
|
||||
public static void setField(Field field, @Nullable Object target, @Nullable Object value) {
|
||||
@@ -641,6 +645,7 @@ public abstract class ReflectionUtils {
|
||||
* <p>Thrown exceptions are handled via a call to {@link #handleReflectionException(Exception)}.
|
||||
* @param field the field to get
|
||||
* @param target the target object from which to get the field
|
||||
* (or {@code null} for a static field)
|
||||
* @return the field's current value
|
||||
*/
|
||||
@Nullable
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -1341,8 +1341,8 @@ public abstract class StringUtils {
|
||||
}
|
||||
|
||||
StringJoiner sj = new StringJoiner(delim);
|
||||
for (Object o : arr) {
|
||||
sj.add(String.valueOf(o));
|
||||
for (Object elem : arr) {
|
||||
sj.add(String.valueOf(elem));
|
||||
}
|
||||
return sj.toString();
|
||||
}
|
||||
|
||||
@@ -57,12 +57,12 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ResourceUrlProvider.class);
|
||||
|
||||
|
||||
private final Map<PathPattern, ResourceWebHandler> handlerMap = new LinkedHashMap<>();
|
||||
|
||||
@Nullable
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
|
||||
@@ -68,6 +68,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
|
||||
private boolean autodetect = true;
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
this.applicationContext = applicationContext;
|
||||
@@ -135,6 +136,7 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
return this.autodetect;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
if (event.getApplicationContext() == this.applicationContext && isAutodetect()) {
|
||||
@@ -146,7 +148,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void detectResourceHandlers(ApplicationContext appContext) {
|
||||
Map<String, SimpleUrlHandlerMapping> beans = appContext.getBeansOfType(SimpleUrlHandlerMapping.class);
|
||||
List<SimpleUrlHandlerMapping> mappings = new ArrayList<>(beans.values());
|
||||
@@ -223,7 +224,6 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
*/
|
||||
@Nullable
|
||||
public final String getForLookupPath(String lookupPath) {
|
||||
|
||||
// Clean duplicate slashes or pathWithinPattern won't match lookupPath
|
||||
String previous;
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user