Skip to content

Commit b617e16

Browse files
committed
Polishing
1 parent 9cf7b0e commit b617e16

File tree

10 files changed

+22
-34
lines changed

10 files changed

+22
-34
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/target/AbstractBeanFactoryBasedTargetSourceCreator.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
6161
private ConfigurableBeanFactory beanFactory;
6262

6363
/** Internally used DefaultListableBeanFactory instances, keyed by bean name. */
64-
private final Map<String, DefaultListableBeanFactory> internalBeanFactories =
65-
new HashMap<>();
64+
private final Map<String, DefaultListableBeanFactory> internalBeanFactories = new HashMap<>();
6665

6766

6867
@Override

spring-aop/src/main/java/org/springframework/aop/target/CommonsPool2TargetSource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ public long getMinEvictableIdleTimeMillis() {
181181
}
182182

183183
/**
184-
* Set whether the call should bock when the pool is exhausted.
184+
* Set whether the call should block when the pool is exhausted.
185185
*/
186186
public void setBlockWhenExhausted(boolean blockWhenExhausted) {
187187
this.blockWhenExhausted = blockWhenExhausted;

spring-aspects/src/main/java/org/springframework/cache/aspectj/AnyThrow.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
package org.springframework.cache.aspectj;
1818

1919
/**
20-
* Utility to trick the compiler to throw a valid checked
21-
* exceptions within the interceptor.
20+
* Utility to trick the compiler to throw valid checked exceptions masked as
21+
* runtime exceptions within the interceptor.
2222
*
2323
* @author Stephane Nicoll
2424
*/
@@ -36,4 +36,5 @@ static void throwUnchecked(Throwable e) {
3636
private static <E extends Throwable> void throwAny(Throwable e) throws E {
3737
throw (E) e;
3838
}
39+
3940
}

spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyBeanDefinitionWrapper.java

+10-22
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
package org.springframework.beans.factory.groovy;
1818

19-
import java.util.ArrayList;
2019
import java.util.Collection;
2120
import java.util.List;
21+
import java.util.Set;
2222

2323
import groovy.lang.GroovyObjectSupport;
2424

@@ -51,18 +51,8 @@ class GroovyBeanDefinitionWrapper extends GroovyObjectSupport {
5151
private static final String DESTROY_METHOD = "destroyMethod";
5252
private static final String SINGLETON = "singleton";
5353

54-
private static final List<String> dynamicProperties = new ArrayList<>(8);
55-
56-
static {
57-
dynamicProperties.add(PARENT);
58-
dynamicProperties.add(AUTOWIRE);
59-
dynamicProperties.add(CONSTRUCTOR_ARGS);
60-
dynamicProperties.add(FACTORY_BEAN);
61-
dynamicProperties.add(FACTORY_METHOD);
62-
dynamicProperties.add(INIT_METHOD);
63-
dynamicProperties.add(DESTROY_METHOD);
64-
dynamicProperties.add(SINGLETON);
65-
}
54+
private static final Set<String> dynamicProperties = Set.of(PARENT, AUTOWIRE, CONSTRUCTOR_ARGS,
55+
FACTORY_BEAN, FACTORY_METHOD, INIT_METHOD, DESTROY_METHOD, SINGLETON);
6656

6757

6858
private String beanName;
@@ -98,11 +88,11 @@ public String getBeanName() {
9888
return this.beanName;
9989
}
10090

101-
public void setBeanDefinition(AbstractBeanDefinition definition) {
91+
void setBeanDefinition(AbstractBeanDefinition definition) {
10292
this.definition = definition;
10393
}
10494

105-
public AbstractBeanDefinition getBeanDefinition() {
95+
AbstractBeanDefinition getBeanDefinition() {
10696
if (this.definition == null) {
10797
this.definition = createBeanDefinition();
10898
}
@@ -126,19 +116,17 @@ protected AbstractBeanDefinition createBeanDefinition() {
126116
return bd;
127117
}
128118

129-
public void setBeanDefinitionHolder(BeanDefinitionHolder holder) {
119+
void setBeanDefinitionHolder(BeanDefinitionHolder holder) {
130120
this.definition = (AbstractBeanDefinition) holder.getBeanDefinition();
131121
this.beanName = holder.getBeanName();
132122
}
133123

134-
public BeanDefinitionHolder getBeanDefinitionHolder() {
124+
BeanDefinitionHolder getBeanDefinitionHolder() {
135125
return new BeanDefinitionHolder(getBeanDefinition(), getBeanName());
136126
}
137127

138-
public void setParent(Object obj) {
139-
if (obj == null) {
140-
throw new IllegalArgumentException("Parent bean cannot be set to a null runtime bean reference!");
141-
}
128+
void setParent(Object obj) {
129+
Assert.notNull(obj, "Parent bean cannot be set to a null runtime bean reference.");
142130
if (obj instanceof String name) {
143131
this.parentName = name;
144132
}
@@ -152,7 +140,7 @@ else if (obj instanceof GroovyBeanDefinitionWrapper wrapper) {
152140
getBeanDefinition().setAbstract(false);
153141
}
154142

155-
public GroovyBeanDefinitionWrapper addProperty(String propertyName, Object propertyValue) {
143+
GroovyBeanDefinitionWrapper addProperty(String propertyName, Object propertyValue) {
156144
if (propertyValue instanceof GroovyBeanDefinitionWrapper wrapper) {
157145
propertyValue = wrapper.getBeanDefinition();
158146
}

spring-beans/src/main/java/org/springframework/beans/factory/groovy/GroovyDynamicElementReader.java

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ public Object invokeMethod(String name, Object obj) {
8888
String myNamespace = this.rootNamespace;
8989
Map<String, String> myNamespaces = this.xmlNamespaces;
9090

91+
@SuppressWarnings("serial")
9192
Closure<Object> callable = new Closure<>(this) {
9293
@Override
9394
public Object call(Object... arguments) {

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1732,7 +1732,7 @@ protected String determineHighestPriorityCandidate(Map<String, Object> candidate
17321732
if (beanInstance != null) {
17331733
Integer candidatePriority = getPriority(beanInstance);
17341734
if (candidatePriority != null) {
1735-
if (highestPriorityBeanName != null) {
1735+
if (highestPriority != null) {
17361736
if (candidatePriority.equals(highestPriority)) {
17371737
throw new NoUniqueBeanDefinitionException(requiredType, candidates.size(),
17381738
"Multiple beans found with the same priority ('" + highestPriority +

spring-context/src/main/java/org/springframework/context/i18n/SimpleTimeZoneAwareLocaleContext.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public TimeZone getTimeZone() {
6161

6262
@Override
6363
public String toString() {
64-
return super.toString() + " " + (this.timeZone != null ? this.timeZone.toString() : "-");
64+
return super.toString() + " " + (this.timeZone != null ? this.timeZone : "-");
6565
}
6666

6767
}

spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResult.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public class DeferredResult<T> {
8080
* Create a DeferredResult.
8181
*/
8282
public DeferredResult() {
83-
this(null, () -> RESULT_NONE);
83+
this(null);
8484
}
8585

8686
/**
@@ -101,8 +101,7 @@ public DeferredResult(Long timeoutValue) {
101101
* @param timeoutResult the result to use
102102
*/
103103
public DeferredResult(@Nullable Long timeoutValue, Object timeoutResult) {
104-
this.timeoutValue = timeoutValue;
105-
this.timeoutResult = () -> timeoutResult;
104+
this(timeoutValue, () -> timeoutResult);
106105
}
107106

108107
/**

spring-web/src/main/java/org/springframework/web/context/request/async/DeferredResultProcessingInterceptor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ default <T> void preProcess(NativeWebRequest request, DeferredResult<T> deferred
7878
* timeout result.
7979
* @param request the current request
8080
* @param deferredResult the DeferredResult for the current request
81-
* @param concurrentResult the result to which the {@code DeferredResult}
81+
* @param concurrentResult the concurrent result
8282
* @throws Exception in case of errors
8383
*/
8484
default <T> void postProcess(NativeWebRequest request, DeferredResult<T> deferredResult,

spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/ProducesRequestCondition.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public final class ProducesRequestCondition extends AbstractRequestCondition<Pro
5757

5858

5959
private final List<ProduceMediaTypeExpression> mediaTypeAllList =
60-
Collections.singletonList(new ProduceMediaTypeExpression(MediaType.ALL_VALUE));
60+
List.of(new ProduceMediaTypeExpression(MediaType.ALL_VALUE));
6161

6262
private final List<ProduceMediaTypeExpression> expressions;
6363

0 commit comments

Comments
 (0)