Skip to content

Commit 130f410

Browse files
committed
Polishing
1 parent 5c20c97 commit 130f410

13 files changed

+53
-48
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ protected void inject(Object bean, String beanName, PropertyValues pvs) throws T
697697
ReflectionUtils.makeAccessible(method);
698698
method.invoke(bean, arguments);
699699
}
700-
catch (InvocationTargetException ex){
700+
catch (InvocationTargetException ex) {
701701
throw ex.getTargetException();
702702
}
703703
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2009 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -55,7 +55,7 @@ public Object getObject(String key) {
5555
if (this.beanFactory.containsBean(key)) {
5656
return this.beanFactory.getBean(key);
5757
}
58-
else if (this.scope != null){
58+
else if (this.scope != null) {
5959
return this.scope.resolveContextualObject(key);
6060
}
6161
else {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -115,7 +115,7 @@ protected String resolvePlaceholder(String placeholder, Properties props) {
115115
*/
116116
protected String resolvePlaceholder(String path, String key, Preferences preferences) {
117117
if (path != null) {
118-
// Do not create the node if it does not exist...
118+
// Do not create the node if it does not exist...
119119
try {
120120
if (preferences.nodeExists(path)) {
121121
return preferences.node(path).get(key, null);

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -64,6 +64,9 @@
6464
*/
6565
public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
6666

67+
/**
68+
* The default bean name separator.
69+
*/
6770
public static final String DEFAULT_BEAN_NAME_SEPARATOR = ".";
6871

6972

@@ -72,7 +75,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
7275
private boolean ignoreInvalidKeys = false;
7376

7477
/**
75-
* Contains names of beans that have overrides
78+
* Contains names of beans that have overrides.
7679
*/
7780
private final Set<String> beanNames = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>(16));
7881

@@ -129,7 +132,7 @@ protected void processKey(ConfigurableListableBeanFactory factory, String key, S
129132
"': expected 'beanName" + this.beanNameSeparator + "property'");
130133
}
131134
String beanName = key.substring(0, separatorIndex);
132-
String beanProperty = key.substring(separatorIndex+1);
135+
String beanProperty = key.substring(separatorIndex + 1);
133136
this.beanNames.add(beanName);
134137
applyPropertyValue(factory, beanName, beanProperty, value);
135138
if (logger.isDebugEnabled()) {
@@ -144,21 +147,22 @@ protected void applyPropertyValue(
144147
ConfigurableListableBeanFactory factory, String beanName, String property, String value) {
145148

146149
BeanDefinition bd = factory.getBeanDefinition(beanName);
147-
while (bd.getOriginatingBeanDefinition() != null) {
150+
BeanDefinition bdToUse = bd;
151+
while (bd != null) {
152+
bdToUse = bd;
148153
bd = bd.getOriginatingBeanDefinition();
149154
}
150155
PropertyValue pv = new PropertyValue(property, value);
151156
pv.setOptional(this.ignoreInvalidKeys);
152-
bd.getPropertyValues().addPropertyValue(pv);
157+
bdToUse.getPropertyValues().addPropertyValue(pv);
153158
}
154159

155160

156161
/**
157162
* Were there overrides for this bean?
158163
* Only valid after processing has occurred at least once.
159164
* @param beanName name of the bean to query status for
160-
* @return whether there were property overrides for
161-
* the named bean
165+
* @return whether there were property overrides for the named bean
162166
*/
163167
public boolean hasPropertyOverridesFor(String beanName) {
164168
return this.beanNames.contains(beanName);

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

Lines changed: 6 additions & 7 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.
@@ -955,7 +955,7 @@ private FactoryBean<?> getNonSingletonFactoryBeanForTypeCheck(String beanName, R
955955
return null;
956956
}
957957

958-
Object instance = null;
958+
Object instance;
959959
try {
960960
// Mark this bean as currently in creation, even if just partially.
961961
beforePrototypeCreation(beanName);
@@ -1068,7 +1068,7 @@ protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd
10681068
"Bean class isn't public, and non-public access not allowed: " + beanClass.getName());
10691069
}
10701070

1071-
if (mbd.getFactoryMethodName() != null) {
1071+
if (mbd.getFactoryMethodName() != null) {
10721072
return instantiateUsingFactoryMethod(beanName, mbd, args);
10731073
}
10741074

@@ -1092,11 +1092,10 @@ protected BeanWrapper createBeanInstance(String beanName, RootBeanDefinition mbd
10921092
}
10931093
}
10941094

1095-
// Need to determine the constructor...
1095+
// Candidate constructors for autowiring?
10961096
Constructor<?>[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName);
1097-
if (ctors != null ||
1098-
mbd.getResolvedAutowireMode() == RootBeanDefinition.AUTOWIRE_CONSTRUCTOR ||
1099-
mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
1097+
if (ctors != null || mbd.getResolvedAutowireMode() == AUTOWIRE_CONSTRUCTOR ||
1098+
mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
11001099
return autowireConstructor(beanName, mbd, ctors, args);
11011100
}
11021101

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> an
574574
*/
575575
@Override
576576
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
577-
throws NoSuchBeanDefinitionException{
577+
throws NoSuchBeanDefinitionException {
578578

579579
A ann = null;
580580
Class<?> beanType = getType(beanName);

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -88,7 +88,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
8888
public static final String SEPARATOR = ".";
8989

9090
/**
91-
* Special key to distinguish {@code owner.(class)=com.myapp.MyClass}-
91+
* Special key to distinguish {@code owner.(class)=com.myapp.MyClass}.
9292
*/
9393
public static final String CLASS_KEY = "(class)";
9494

@@ -300,10 +300,10 @@ public int registerBeanDefinitions(ResourceBundle rb, String prefix) throws Bean
300300

301301

302302
/**
303-
* Register bean definitions contained in a Map,
304-
* using all property keys (i.e. not filtering by prefix).
305-
* @param map Map: name -> property (String or Object). Property values
306-
* will be strings if coming from a Properties file etc. Property names
303+
* Register bean definitions contained in a Map, using all property keys (i.e. not
304+
* filtering by prefix).
305+
* @param map a map of {@code name} to {@code property} (String or Object). Property
306+
* values will be strings if coming from a Properties file etc. Property names
307307
* (keys) <b>must</b> be Strings. Class keys must be Strings.
308308
* @return the number of bean definitions found
309309
* @throws BeansException in case of loading or parsing errors
@@ -316,8 +316,8 @@ public int registerBeanDefinitions(Map<?, ?> map) throws BeansException {
316316
/**
317317
* Register bean definitions contained in a Map.
318318
* Ignore ineligible properties.
319-
* @param map Map name -> property (String or Object). Property values
320-
* will be strings if coming from a Properties file etc. Property names
319+
* @param map a map of {@code name} to {@code property} (String or Object). Property
320+
* values will be strings if coming from a Properties file etc. Property names
321321
* (keys) <b>must</b> be Strings. Class keys must be Strings.
322322
* @param prefix a filter within the keys in the map: e.g. 'beans.'
323323
* (can be empty or {@code null})
@@ -331,9 +331,9 @@ public int registerBeanDefinitions(Map<?, ?> map, String prefix) throws BeansExc
331331
/**
332332
* Register bean definitions contained in a Map.
333333
* Ignore ineligible properties.
334-
* @param map Map name -> property (String or Object). Property values
335-
* will be strings if coming from a Properties file etc. Property names
336-
* (keys) <b>must</b> be strings. Class keys must be Strings.
334+
* @param map a map of {@code name} to {@code property} (String or Object). Property
335+
* values will be strings if coming from a Properties file etc. Property names
336+
* (keys) <b>must</b> be Strings. Class keys must be Strings.
337337
* @param prefix a filter within the keys in the map: e.g. 'beans.'
338338
* (can be empty or {@code null})
339339
* @param resourceDescription description of the resource that the
@@ -393,9 +393,9 @@ public int registerBeanDefinitions(Map<?, ?> map, String prefix, String resource
393393

394394
/**
395395
* Get all property values, given a prefix (which will be stripped)
396-
* and add the bean they define to the factory with the given name
396+
* and add the bean they define to the factory with the given name.
397397
* @param beanName name of the bean to define
398-
* @param map Map containing string pairs
398+
* @param map a Map containing string pairs
399399
* @param prefix prefix of each entry, which will be stripped
400400
* @param resourceDescription description of the resource that the
401401
* Map came from (for logging purposes)
@@ -502,7 +502,7 @@ else if (property.endsWith(REF_SUFFIX)) {
502502
* Reads the value of the entry. Correctly interprets bean references for
503503
* values that are prefixed with an asterisk.
504504
*/
505-
private Object readValue(Map.Entry<? ,?> entry) {
505+
private Object readValue(Map.Entry<?, ?> entry) {
506506
Object val = entry.getValue();
507507
if (val instanceof String) {
508508
String strVal = (String) val;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public Map<String, Object> getBeansWithAnnotation(Class<? extends Annotation> an
351351

352352
@Override
353353
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
354-
throws NoSuchBeanDefinitionException{
354+
throws NoSuchBeanDefinitionException {
355355

356356
Class<?> beanType = getType(beanName);
357357
return (beanType != null ? AnnotationUtils.findAnnotation(beanType, annotationType) : null);

spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
*
4444
* <p>The format of {@code META-INF/spring.schemas} is a properties file where each line
4545
* should be of the form {@code systemId=schema-location} where {@code schema-location}
46-
* should also be a schema file in the classpath. Since systemId is commonly a URL,
47-
* one must be careful to escape any ':' characters which are treated as delimiters
46+
* should also be a schema file in the classpath. Since {@code systemId} is commonly a
47+
* URL, one must be careful to escape any ':' characters which are treated as delimiters
4848
* in properties files.
4949
*
50-
* <p>The pattern for the mapping files can be overidden using the
51-
* {@link #PluggableSchemaResolver(ClassLoader, String)} constructor
50+
* <p>The pattern for the mapping files can be overridden using the
51+
* {@link #PluggableSchemaResolver(ClassLoader, String)} constructor.
5252
*
5353
* @author Rob Harrop
5454
* @author Juergen Hoeller

spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -116,7 +116,7 @@ public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition,
116116
"Constructor argument '" + argName + "' specifies a negative index", attr);
117117
}
118118

119-
if (cvs.hasIndexedArgumentValue(index)){
119+
if (cvs.hasIndexedArgumentValue(index)) {
120120
parserContext.getReaderContext().error(
121121
"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
122122
" Only one approach may be used per argument.", attr);
@@ -128,7 +128,7 @@ public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition,
128128
// no escaping -> ctr name
129129
else {
130130
String name = Conventions.attributeNameToPropertyName(argName);
131-
if (containsArgWithName(name, cvs)){
131+
if (containsArgWithName(name, cvs)) {
132132
parserContext.getReaderContext().error(
133133
"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
134134
" Only one approach may be used per argument.", attr);

0 commit comments

Comments
 (0)