diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java index 50a9734bdf4..6be81e9f547 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AbstractAutoProxyCreator.java @@ -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 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)); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java index cf13a408173..14427fee93e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionReader.java @@ -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)); } } diff --git a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java index 9b9decee735..89dfab86648 100644 --- a/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ReflectionUtils.java @@ -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 methods = new ArrayList<>(32); + final List 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 methods = new ArrayList<>(32); + final List 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 { *

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 { *

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 diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 7867cda6713..d19cd4bd868 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -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(); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java index 2146fbdde3f..b78d8532008 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/resource/ResourceUrlProvider.java @@ -57,12 +57,12 @@ public class ResourceUrlProvider implements ApplicationListener handlerMap = new LinkedHashMap<>(); @Nullable private ApplicationContext applicationContext; + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { this.applicationContext = applicationContext; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java index 28807ac5948..e73fcbaa59f 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceUrlProvider.java @@ -68,6 +68,7 @@ public class ResourceUrlProvider implements ApplicationListener beans = appContext.getBeansOfType(SimpleUrlHandlerMapping.class); List mappings = new ArrayList<>(beans.values()); @@ -223,7 +224,6 @@ public class ResourceUrlProvider implements ApplicationListener