diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java index ff9a03f15c..ac32f85e89 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java @@ -61,8 +61,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator private ConfigurableBeanFactory beanFactory; /** Internally used DefaultListableBeanFactory instances, keyed by bean name. */ - private final Map internalBeanFactories = - new HashMap<>(); + private final Map internalBeanFactories = new HashMap<>(); @Override diff --git a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java index 4733d02696..8631f0705d 100644 --- a/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java +++ b/spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java @@ -181,7 +181,7 @@ public class CommonsPool2TargetSource extends AbstractPoolingTargetSource implem } /** - * Set whether the call should bock when the pool is exhausted. + * Set whether the call should block when the pool is exhausted. */ public void setBlockWhenExhausted(boolean blockWhenExhausted) { this.blockWhenExhausted = blockWhenExhausted; diff --git a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java index c59bce7b75..158cf83b46 100644 --- a/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java +++ b/spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java @@ -17,8 +17,8 @@ package org.springframework.cache.aspectj; /** - * Utility to trick the compiler to throw a valid checked - * exceptions within the interceptor. + * Utility to trick the compiler to throw valid checked exceptions masked as + * runtime exceptions within the interceptor. * * @author Stephane Nicoll */ @@ -36,4 +36,5 @@ final class AnyThrow { private static void throwAny(Throwable e) throws E { throw (E) e; } + } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java index 3691e66aa9..6b8e2b601e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java @@ -16,9 +16,9 @@ package org.springframework.beans.factory.groovy; -import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Set; import groovy.lang.GroovyObjectSupport; @@ -51,18 +51,8 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport { private static final String DESTROY_METHOD = "destroyMethod"; private static final String SINGLETON = "singleton"; - private static final List dynamicProperties = new ArrayList<>(8); - - static { - dynamicProperties.add(PARENT); - dynamicProperties.add(AUTOWIRE); - dynamicProperties.add(CONSTRUCTOR_ARGS); - dynamicProperties.add(FACTORY_BEAN); - dynamicProperties.add(FACTORY_METHOD); - dynamicProperties.add(INIT_METHOD); - dynamicProperties.add(DESTROY_METHOD); - dynamicProperties.add(SINGLETON); - } + private static final Set dynamicProperties = Set.of(PARENT, AUTOWIRE, CONSTRUCTOR_ARGS, + FACTORY_BEAN, FACTORY_METHOD, INIT_METHOD, DESTROY_METHOD, SINGLETON); private String beanName; @@ -98,11 +88,11 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport { return this.beanName; } - public void setBeanDefinition(AbstractBeanDefinition definition) { + void setBeanDefinition(AbstractBeanDefinition definition) { this.definition = definition; } - public AbstractBeanDefinition getBeanDefinition() { + AbstractBeanDefinition getBeanDefinition() { if (this.definition == null) { this.definition = createBeanDefinition(); } @@ -126,19 +116,17 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport { return bd; } - public void setBeanDefinitionHolder(BeanDefinitionHolder holder) { + void setBeanDefinitionHolder(BeanDefinitionHolder holder) { this.definition = (AbstractBeanDefinition) holder.getBeanDefinition(); this.beanName = holder.getBeanName(); } - public BeanDefinitionHolder getBeanDefinitionHolder() { + BeanDefinitionHolder getBeanDefinitionHolder() { return new BeanDefinitionHolder(getBeanDefinition(), getBeanName()); } - public void setParent(Object obj) { - if (obj == null) { - throw new IllegalArgumentException("Parent bean cannot be set to a null runtime bean reference!"); - } + void setParent(Object obj) { + Assert.notNull(obj, "Parent bean cannot be set to a null runtime bean reference."); if (obj instanceof String name) { this.parentName = name; } @@ -152,7 +140,7 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport { getBeanDefinition().setAbstract(false); } - public GroovyBeanDefinitionWrapper addProperty(String propertyName, Object propertyValue) { + GroovyBeanDefinitionWrapper addProperty(String propertyName, Object propertyValue) { if (propertyValue instanceof GroovyBeanDefinitionWrapper wrapper) { propertyValue = wrapper.getBeanDefinition(); } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyDynamicElementReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyDynamicElementReader.java index bcab348fec..3e714247a7 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyDynamicElementReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyDynamicElementReader.java @@ -88,6 +88,7 @@ class GroovyDynamicElementReader extends GroovyObjectSupport { String myNamespace = this.rootNamespace; Map myNamespaces = this.xmlNamespaces; + @SuppressWarnings("serial") Closure callable = new Closure<>(this) { @Override public Object call(Object... arguments) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 14cad2960b..baa50d9566 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -1732,7 +1732,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto if (beanInstance != null) { Integer candidatePriority = getPriority(beanInstance); if (candidatePriority != null) { - if (highestPriorityBeanName != null) { + if (highestPriority != null) { if (candidatePriority.equals(highestPriority)) { throw new NoUniqueBeanDefinitionException(requiredType, candidates.size(), "Multiple beans found with the same priority ('" + highestPriority + diff --git a/spring-context/src/main/java/org/springframework/context/i18n/SimpleTimeZoneAwareLocaleContext.java b/spring-context/src/main/java/org/springframework/context/i18n/SimpleTimeZoneAwareLocaleContext.java index 0ce008d35c..cdd6da780b 100644 --- a/spring-context/src/main/java/org/springframework/context/i18n/SimpleTimeZoneAwareLocaleContext.java +++ b/spring-context/src/main/java/org/springframework/context/i18n/SimpleTimeZoneAwareLocaleContext.java @@ -61,7 +61,7 @@ public class SimpleTimeZoneAwareLocaleContext extends SimpleLocaleContext implem @Override public String toString() { - return super.toString() + " " + (this.timeZone != null ? this.timeZone.toString() : "-"); + return super.toString() + " " + (this.timeZone != null ? this.timeZone : "-"); } } diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java index ab328cd012..30bb0a9217 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java @@ -80,7 +80,7 @@ public class DeferredResult { * Create a DeferredResult. */ public DeferredResult() { - this(null, () -> RESULT_NONE); + this(null); } /** @@ -101,8 +101,7 @@ public class DeferredResult { * @param timeoutResult the result to use */ public DeferredResult(@Nullable Long timeoutValue, Object timeoutResult) { - this.timeoutValue = timeoutValue; - this.timeoutResult = () -> timeoutResult; + this(timeoutValue, () -> timeoutResult); } /** diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java index 4144a098af..e181636a61 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java @@ -78,7 +78,7 @@ public interface DeferredResultProcessingInterceptor { * timeout result. * @param request the current request * @param deferredResult the DeferredResult for the current request - * @param concurrentResult the result to which the {@code DeferredResult} + * @param concurrentResult the concurrent result * @throws Exception in case of errors */ default void postProcess(NativeWebRequest request, DeferredResult deferredResult, diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java index 56d75796be..590d2af771 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java @@ -57,7 +57,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition mediaTypeAllList = - Collections.singletonList(new ProduceMediaTypeExpression(MediaType.ALL_VALUE)); + List.of(new ProduceMediaTypeExpression(MediaType.ALL_VALUE)); private final List expressions;