Skip to content

Commit 7dc92aa

Browse files
committed
Polishing
1 parent 1956cb1 commit 7dc92aa

File tree

30 files changed

+82
-106
lines changed

30 files changed

+82
-106
lines changed

spring-beans/src/main/java/org/springframework/beans/PropertyValue.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -169,7 +169,7 @@ public synchronized boolean isConverted() {
169169
}
170170

171171
/**
172-
* Set the converted value of the constructor argument,
172+
* Set the converted value of this property value,
173173
* after processed type conversion.
174174
*/
175175
public synchronized void setConvertedValue(@Nullable Object value) {
@@ -178,7 +178,7 @@ public synchronized void setConvertedValue(@Nullable Object value) {
178178
}
179179

180180
/**
181-
* Return the converted value of the constructor argument,
181+
* Return the converted value of this property value,
182182
* after processed type conversion.
183183
*/
184184
@Nullable

spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public boolean equals(Object other) {
180180
if (this == other) {
181181
return true;
182182
}
183-
if (getClass() != other.getClass()) {
183+
if (other == null || getClass() != other.getClass()) {
184184
return false;
185185
}
186186
InjectionPoint otherPoint = (InjectionPoint) other;

spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionVisitor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected void visitArray(Object[] arrayVal) {
234234
}
235235
}
236236

237-
@SuppressWarnings({"unchecked", "rawtypes"})
237+
@SuppressWarnings({"rawtypes", "unchecked"})
238238
protected void visitList(List listVal) {
239239
for (int i = 0; i < listVal.size(); i++) {
240240
Object elem = listVal.get(i);
@@ -245,7 +245,7 @@ protected void visitList(List listVal) {
245245
}
246246
}
247247

248-
@SuppressWarnings({"unchecked", "rawtypes"})
248+
@SuppressWarnings({"rawtypes", "unchecked"})
249249
protected void visitSet(Set setVal) {
250250
Set newContent = new LinkedHashSet();
251251
boolean entriesModified = false;
@@ -262,7 +262,7 @@ protected void visitSet(Set setVal) {
262262
}
263263
}
264264

265-
@SuppressWarnings({"unchecked", "rawtypes"})
265+
@SuppressWarnings({"rawtypes", "unchecked"})
266266
protected void visitMap(Map<?, ?> mapVal) {
267267
Map newContent = new LinkedHashMap();
268268
boolean entriesModified = false;

spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626
* @author Rod Johnson
2727
* @author Juergen Hoeller
2828
* @see BeanDefinition#getPropertyValues()
29-
* @see org.springframework.beans.factory.BeanFactory#getBean
29+
* @see org.springframework.beans.factory.BeanFactory#getBean(String)
3030
*/
3131
public class RuntimeBeanReference implements BeanReference {
3232

@@ -39,9 +39,7 @@ public class RuntimeBeanReference implements BeanReference {
3939

4040

4141
/**
42-
* Create a new RuntimeBeanReference to the given bean name,
43-
* without explicitly marking it as reference to a bean in
44-
* the parent factory.
42+
* Create a new RuntimeBeanReference to the given bean name.
4543
* @param beanName name of the target bean
4644
*/
4745
public RuntimeBeanReference(String beanName) {
@@ -50,11 +48,10 @@ public RuntimeBeanReference(String beanName) {
5048

5149
/**
5250
* Create a new RuntimeBeanReference to the given bean name,
53-
* with the option to mark it as reference to a bean in
54-
* the parent factory.
51+
* with the option to mark it as reference to a bean in the parent factory.
5552
* @param beanName name of the target bean
56-
* @param toParent whether this is an explicit reference to
57-
* a bean in the parent factory
53+
* @param toParent whether this is an explicit reference to a bean in the
54+
* parent factory
5855
*/
5956
public RuntimeBeanReference(String beanName, boolean toParent) {
6057
Assert.hasText(beanName, "'beanName' must not be empty");
@@ -69,8 +66,7 @@ public String getBeanName() {
6966
}
7067

7168
/**
72-
* Return whether this is an explicit reference to a bean
73-
* in the parent factory.
69+
* Return whether this is an explicit reference to a bean in the parent factory.
7470
*/
7571
public boolean isToParent() {
7672
return this.toParent;

spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -117,15 +117,15 @@ public Class<?> getObjectType() {
117117
* case of a shared singleton; else, on each {@link #getObject()} call.
118118
* <p>The default implementation returns the merged {@code Map} instance.
119119
* @return the object returned by this factory
120-
* @see #process(java.util.Map, MatchCallback)
120+
* @see #process(MatchCallback)
121121
*/
122122
protected Map<String, Object> createMap() {
123123
Map<String, Object> result = new LinkedHashMap<>();
124124
process((properties, map) -> merge(result, map));
125125
return result;
126126
}
127127

128-
@SuppressWarnings({"unchecked", "rawtypes"})
128+
@SuppressWarnings({"rawtypes", "unchecked"})
129129
private void merge(Map<String, Object> output, Map<String, Object> map) {
130130
map.forEach((key, value) -> {
131131
Object existing = output.get(key);

spring-beans/src/main/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -128,7 +128,7 @@ public Class<?> getObjectType() {
128128
* <p>Invoked lazily the first time {@link #getObject()} is invoked in
129129
* case of a shared singleton; else, on each {@link #getObject()} call.
130130
* @return the object returned by this factory
131-
* @see #process(MatchCallback) ()
131+
* @see #process(MatchCallback)
132132
*/
133133
protected Properties createProperties() {
134134
Properties result = CollectionFactory.createStringAdaptingProperties();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
6565
public static final String SCOPE_DEFAULT = "";
6666

6767
/**
68-
* Constant that indicates no autowiring at all.
68+
* Constant that indicates no external autowiring at all.
6969
* @see #setAutowireMode
7070
*/
7171
public static final int AUTOWIRE_NO = AutowireCapableBeanFactory.AUTOWIRE_NO;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1648,7 +1648,7 @@ protected Object getObjectForBeanInstance(
16481648
return beanInstance;
16491649
}
16501650
if (!(beanInstance instanceof FactoryBean)) {
1651-
throw new BeanIsNotAFactoryException(transformedBeanName(name), beanInstance.getClass());
1651+
throw new BeanIsNotAFactoryException(beanName, beanInstance.getClass());
16521652
}
16531653
}
16541654

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -180,6 +180,8 @@ public BeanDefinitionBuilder setFactoryMethod(String factoryMethod) {
180180
/**
181181
* Set the name of a non-static factory method to use for this definition,
182182
* including the bean name of the factory instance to call the method on.
183+
* @param factoryMethod the name of the factory method
184+
* @param factoryBean the name of the bean to call the specified factory method on
183185
* @since 4.3.6
184186
*/
185187
public BeanDefinitionBuilder setFactoryMethodOnBean(String factoryMethod, String factoryBean) {
@@ -209,7 +211,7 @@ public BeanDefinitionBuilder addConstructorArgReference(String beanName) {
209211
}
210212

211213
/**
212-
* Add the supplied property value under the given name.
214+
* Add the supplied property value under the given property name.
213215
*/
214216
public BeanDefinitionBuilder addPropertyValue(String name, @Nullable Object value) {
215217
this.beanDefinition.getPropertyValues().add(name, value);

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -385,8 +385,7 @@ private Object resolveReference(Object argName, RuntimeBeanReference ref) {
385385
private Object resolveManagedArray(Object argName, List<?> ml, Class<?> elementType) {
386386
Object resolved = Array.newInstance(elementType, ml.size());
387387
for (int i = 0; i < ml.size(); i++) {
388-
Array.set(resolved, i,
389-
resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
388+
Array.set(resolved, i, resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
390389
}
391390
return resolved;
392391
}
@@ -397,8 +396,7 @@ private Object resolveManagedArray(Object argName, List<?> ml, Class<?> elementT
397396
private List<?> resolveManagedList(Object argName, List<?> ml) {
398397
List<Object> resolved = new ArrayList<>(ml.size());
399398
for (int i = 0; i < ml.size(); i++) {
400-
resolved.add(
401-
resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
399+
resolved.add(resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
402400
}
403401
return resolved;
404402
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -176,7 +176,7 @@ public RootBeanDefinition getBeanDefinition() {
176176

177177
@Override
178178
public boolean equals(Object other) {
179-
return (getClass() == other.getClass() &&
179+
return (other != null && getClass() == other.getClass() &&
180180
this.beanDefinition.equals(((CglibIdentitySupport) other).beanDefinition));
181181
}
182182

spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,9 @@
2323
import org.springframework.beans.factory.config.BeanDefinition;
2424
import org.springframework.tests.sample.beans.TestBean;
2525

26-
import static org.junit.Assert.*;
26+
import static org.junit.Assert.assertEquals;
27+
import static org.junit.Assert.assertFalse;
28+
import static org.junit.Assert.assertTrue;
2729

2830
/**
2931
* @author Rod Johnson
@@ -36,9 +38,9 @@ public void beanClassWithSimpleProperty() {
3638
String[] dependsOn = new String[] { "A", "B", "C" };
3739
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
3840
bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE);
39-
bdb.addPropertyReference("age", "15");
40-
for (int i = 0; i < dependsOn.length; i++) {
41-
bdb.addDependsOn(dependsOn[i]);
41+
bdb.addPropertyValue("age", "15");
42+
for (String dependsOnEntry : dependsOn) {
43+
bdb.addDependsOn(dependsOnEntry);
4244
}
4345

4446
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();

spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -61,8 +61,6 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
6161

6262
private ITestBean spouse;
6363

64-
protected ITestBean[] spouses;
65-
6664
private String touchy;
6765

6866
private String[] stringArray;

spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ protected void invokeListener(ApplicationListener<?> listener, ApplicationEvent
166166
}
167167
}
168168

169-
@SuppressWarnings({"unchecked", "rawtypes"})
169+
@SuppressWarnings({"rawtypes", "unchecked"})
170170
private void doInvokeListener(ApplicationListener listener, ApplicationEvent event) {
171171
try {
172172
listener.onApplicationEvent(event);

spring-core/src/main/java/org/springframework/core/CollectionFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public static boolean isApproximableMapType(@Nullable Class<?> mapType) {
241241
* @see java.util.TreeMap
242242
* @see java.util.LinkedHashMap
243243
*/
244-
@SuppressWarnings({"unchecked", "rawtypes"})
244+
@SuppressWarnings({"rawtypes", "unchecked"})
245245
public static <K, V> Map<K, V> createApproximateMap(@Nullable Object map, int capacity) {
246246
if (map instanceof EnumMap) {
247247
EnumMap enumMap = new EnumMap((EnumMap) map);
@@ -294,7 +294,7 @@ public static <K, V> Map<K, V> createMap(Class<?> mapType, int capacity) {
294294
* {@code null}; or if the desired {@code mapType} is {@link EnumMap} and
295295
* the supplied {@code keyType} is not a subtype of {@link Enum}
296296
*/
297-
@SuppressWarnings({"unchecked", "rawtypes"})
297+
@SuppressWarnings({"rawtypes", "unchecked"})
298298
public static <K, V> Map<K, V> createMap(Class<?> mapType, @Nullable Class<?> keyType, int capacity) {
299299
Assert.notNull(mapType, "Map type must not be null");
300300
if (mapType.isInterface()) {

spring-core/src/main/java/org/springframework/core/convert/support/IntegerToEnumConverterFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,7 +26,7 @@
2626
* @author Stephane Nicoll
2727
* @since 4.3
2828
*/
29-
@SuppressWarnings({"unchecked", "rawtypes"})
29+
@SuppressWarnings({"rawtypes", "unchecked"})
3030
final class IntegerToEnumConverterFactory implements ConverterFactory<Integer, Enum> {
3131

3232
@Override

spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* @author Stephane Nicoll
2727
* @since 3.0
2828
*/
29-
@SuppressWarnings({"unchecked", "rawtypes"})
29+
@SuppressWarnings({"rawtypes", "unchecked"})
3030
final class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {
3131

3232
@Override

spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -383,7 +383,7 @@ public MutablePropertySources getPropertySources() {
383383
}
384384

385385
@Override
386-
@SuppressWarnings({"unchecked", "rawtypes"})
386+
@SuppressWarnings({"rawtypes", "unchecked"})
387387
public Map<String, Object> getSystemProperties() {
388388
try {
389389
return (Map) System.getProperties();
@@ -409,7 +409,7 @@ protected String getSystemAttribute(String attributeName) {
409409
}
410410

411411
@Override
412-
@SuppressWarnings({"unchecked", "rawtypes"})
412+
@SuppressWarnings({"rawtypes", "unchecked"})
413413
public Map<String, Object> getSystemEnvironment() {
414414
if (suppressGetenvAccess()) {
415415
return Collections.emptyMap();

spring-core/src/main/java/org/springframework/core/env/StandardEnvironment.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -75,8 +75,10 @@ public class StandardEnvironment extends AbstractEnvironment {
7575
*/
7676
@Override
7777
protected void customizePropertySources(MutablePropertySources propertySources) {
78-
propertySources.addLast(new MapPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, getSystemProperties()));
79-
propertySources.addLast(new SystemEnvironmentPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment()));
78+
propertySources.addLast(
79+
new PropertiesPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, getSystemProperties()));
80+
propertySources.addLast(
81+
new SystemEnvironmentPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment()));
8082
}
8183

8284
}

0 commit comments

Comments
 (0)