Browse Source

Polishing

pull/22521/head
Juergen Hoeller 6 years ago
parent
commit
aa89a57953
  1. 2
      spring-beans/src/main/java/org/springframework/beans/factory/annotation/AutowiredAnnotationBeanPostProcessor.java
  2. 4
      spring-beans/src/main/java/org/springframework/beans/factory/config/BeanExpressionContext.java
  3. 4
      spring-beans/src/main/java/org/springframework/beans/factory/config/PreferencesPlaceholderConfigurer.java
  4. 9
      spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyOverrideConfigurer.java
  5. 8
      spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractAutowireCapableBeanFactory.java
  6. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java
  7. 26
      spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java
  8. 4
      spring-beans/src/main/java/org/springframework/beans/factory/support/SimpleInstantiationStrategy.java
  9. 2
      spring-beans/src/main/java/org/springframework/beans/factory/support/StaticListableBeanFactory.java
  10. 8
      spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java
  11. 6
      spring-beans/src/main/java/org/springframework/beans/factory/xml/SimpleConstructorNamespaceHandler.java
  12. 4
      spring-core/src/main/java/org/springframework/core/AttributeAccessor.java
  13. 4
      spring-core/src/main/java/org/springframework/util/ClassUtils.java
  14. 6
      spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java

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

@ -695,7 +695,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean @@ -695,7 +695,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
ReflectionUtils.makeAccessible(method);
method.invoke(bean, arguments);
}
catch (InvocationTargetException ex){
catch (InvocationTargetException ex) {
throw ex.getTargetException();
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -59,7 +59,7 @@ public class BeanExpressionContext { @@ -59,7 +59,7 @@ public class BeanExpressionContext {
if (this.beanFactory.containsBean(key)) {
return this.beanFactory.getBean(key);
}
else if (this.scope != null){
else if (this.scope != null) {
return this.scope.resolveContextualObject(key);
}
else {

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -121,7 +121,7 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu @@ -121,7 +121,7 @@ public class PreferencesPlaceholderConfigurer extends PropertyPlaceholderConfigu
@Nullable
protected String resolvePlaceholder(@Nullable String path, String key, Preferences preferences) {
if (path != null) {
// Do not create the node if it does not exist...
// Do not create the node if it does not exist...
try {
if (preferences.nodeExists(path)) {
return preferences.node(path).get(key, null);

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -64,6 +64,9 @@ import org.springframework.beans.factory.BeanInitializationException; @@ -64,6 +64,9 @@ import org.springframework.beans.factory.BeanInitializationException;
*/
public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
/**
* The default bean name separator.
*/
public static final String DEFAULT_BEAN_NAME_SEPARATOR = ".";
@ -72,7 +75,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer { @@ -72,7 +75,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
private boolean ignoreInvalidKeys = false;
/**
* Contains names of beans that have overrides
* Contains names of beans that have overrides.
*/
private final Set<String> beanNames = Collections.newSetFromMap(new ConcurrentHashMap<>(16));
@ -129,7 +132,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer { @@ -129,7 +132,7 @@ public class PropertyOverrideConfigurer extends PropertyResourceConfigurer {
"': expected 'beanName" + this.beanNameSeparator + "property'");
}
String beanName = key.substring(0, separatorIndex);
String beanProperty = key.substring(separatorIndex+1);
String beanProperty = key.substring(separatorIndex + 1);
this.beanNames.add(beanName);
applyPropertyValue(factory, beanName, beanProperty, value);
if (logger.isDebugEnabled()) {

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@ -971,7 +971,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -971,7 +971,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
return null;
}
Object instance = null;
Object instance;
try {
// Mark this bean as currently in creation, even if just partially.
beforePrototypeCreation(beanName);
@ -1092,7 +1092,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -1092,7 +1092,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
return obtainFromSupplier(instanceSupplier, beanName);
}
if (mbd.getFactoryMethodName() != null) {
if (mbd.getFactoryMethodName() != null) {
return instantiateUsingFactoryMethod(beanName, mbd, args);
}
@ -1119,7 +1119,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac @@ -1119,7 +1119,7 @@ public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFac
// Candidate constructors for autowiring?
Constructor<?>[] ctors = determineConstructorsFromBeanPostProcessors(beanClass, beanName);
if (ctors != null || mbd.getResolvedAutowireMode() == AUTOWIRE_CONSTRUCTOR ||
mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
mbd.hasConstructorArgumentValues() || !ObjectUtils.isEmpty(args)) {
return autowireConstructor(beanName, mbd, ctors, args);
}

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

@ -572,7 +572,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @@ -572,7 +572,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{
throws NoSuchBeanDefinitionException {
A ann = null;
Class<?> beanType = getType(beanName);

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

@ -89,7 +89,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader @@ -89,7 +89,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
public static final String SEPARATOR = ".";
/**
* Special key to distinguish {@code owner.(class)=com.myapp.MyClass}-
* Special key to distinguish {@code owner.(class)=com.myapp.MyClass}.
*/
public static final String CLASS_KEY = "(class)";
@ -299,10 +299,10 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader @@ -299,10 +299,10 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Register bean definitions contained in a Map,
* using all property keys (i.e. not filtering by prefix).
* @param map Map: name -> property (String or Object). Property values
* will be strings if coming from a Properties file etc. Property names
* Register bean definitions contained in a Map, using all property keys (i.e. not
* filtering by prefix).
* @param map a map of {@code name} to {@code property} (String or Object). Property
* values will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be Strings. Class keys must be Strings.
* @return the number of bean definitions found
* @throws BeansException in case of loading or parsing errors
@ -315,8 +315,8 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader @@ -315,8 +315,8 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Register bean definitions contained in a Map.
* Ignore ineligible properties.
* @param map Map name -> property (String or Object). Property values
* will be strings if coming from a Properties file etc. Property names
* @param map a map of {@code name} to {@code property} (String or Object). Property
* values will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be Strings. Class keys must be Strings.
* @param prefix a filter within the keys in the map: e.g. 'beans.'
* (can be empty or {@code null})
@ -330,9 +330,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader @@ -330,9 +330,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Register bean definitions contained in a Map.
* Ignore ineligible properties.
* @param map Map name -> property (String or Object). Property values
* will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be strings. Class keys must be Strings.
* @param map a map of {@code name} to {@code property} (String or Object). Property
* values will be strings if coming from a Properties file etc. Property names
* (keys) <b>must</b> be Strings. Class keys must be Strings.
* @param prefix a filter within the keys in the map: e.g. 'beans.'
* (can be empty or {@code null})
* @param resourceDescription description of the resource that the
@ -392,9 +392,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader @@ -392,9 +392,9 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
/**
* Get all property values, given a prefix (which will be stripped)
* and add the bean they define to the factory with the given name
* and add the bean they define to the factory with the given name.
* @param beanName name of the bean to define
* @param map Map containing string pairs
* @param map a Map containing string pairs
* @param prefix prefix of each entry, which will be stripped
* @param resourceDescription description of the resource that the
* Map came from (for logging purposes)
@ -501,7 +501,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader @@ -501,7 +501,7 @@ public class PropertiesBeanDefinitionReader extends AbstractBeanDefinitionReader
* Reads the value of the entry. Correctly interprets bean references for
* values that are prefixed with an asterisk.
*/
private Object readValue(Map.Entry<? ,?> entry) {
private Object readValue(Map.Entry<?, ?> entry) {
Object val = entry.getValue();
if (val instanceof String) {
String strVal = (String) val;

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -75,7 +75,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy { @@ -75,7 +75,7 @@ public class SimpleInstantiationStrategy implements InstantiationStrategy {
(PrivilegedExceptionAction<Constructor<?>>) clazz::getDeclaredConstructor);
}
else {
constructorToUse = clazz.getDeclaredConstructor();
constructorToUse = clazz.getDeclaredConstructor();
}
bd.resolvedConstructorOrFactoryMethod = constructorToUse;
}

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

@ -357,7 +357,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory { @@ -357,7 +357,7 @@ public class StaticListableBeanFactory implements ListableBeanFactory {
@Override
@Nullable
public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> annotationType)
throws NoSuchBeanDefinitionException{
throws NoSuchBeanDefinitionException {
Class<?> beanType = getType(beanName);
return (beanType != null ? AnnotationUtils.findAnnotation(beanType, annotationType) : null);

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

@ -44,12 +44,12 @@ import org.springframework.util.CollectionUtils; @@ -44,12 +44,12 @@ import org.springframework.util.CollectionUtils;
*
* <p>The format of {@code META-INF/spring.schemas} is a properties file where each line
* should be of the form {@code systemId=schema-location} where {@code schema-location}
* should also be a schema file in the classpath. Since systemId is commonly a URL,
* one must be careful to escape any ':' characters which are treated as delimiters
* should also be a schema file in the classpath. Since {@code systemId} is commonly a
* URL, one must be careful to escape any ':' characters which are treated as delimiters
* in properties files.
*
* <p>The pattern for the mapping files can be overidden using the
* {@link #PluggableSchemaResolver(ClassLoader, String)} constructor
* <p>The pattern for the mapping files can be overridden using the
* {@link #PluggableSchemaResolver(ClassLoader, String)} constructor.
*
* @author Rob Harrop
* @author Juergen Hoeller

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 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.
@ -118,7 +118,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler { @@ -118,7 +118,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
"Constructor argument '" + argName + "' specifies a negative index", attr);
}
if (cvs.hasIndexedArgumentValue(index)){
if (cvs.hasIndexedArgumentValue(index)) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' with index "+ index+" already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);
@ -130,7 +130,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler { @@ -130,7 +130,7 @@ public class SimpleConstructorNamespaceHandler implements NamespaceHandler {
// no escaping -> ctr name
else {
String name = Conventions.attributeNameToPropertyName(argName);
if (containsArgWithName(name, cvs)){
if (containsArgWithName(name, cvs)) {
parserContext.getReaderContext().error(
"Constructor argument '" + argName + "' already defined using <constructor-arg>." +
" Only one approach may be used per argument.", attr);

4
spring-core/src/main/java/org/springframework/core/AttributeAccessor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2018 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.
@ -28,7 +28,7 @@ import org.springframework.lang.Nullable; @@ -28,7 +28,7 @@ import org.springframework.lang.Nullable;
public interface AttributeAccessor {
/**
* Set the attribute defined by {@code name} to the supplied {@code value}.
* Set the attribute defined by {@code name} to the supplied {@code value}.
* If {@code value} is {@code null}, the attribute is {@link #removeAttribute removed}.
* <p>In general, users should take care to prevent overlaps with other
* metadata attributes by using fully-qualified names, perhaps using

4
spring-core/src/main/java/org/springframework/util/ClassUtils.java

@ -759,9 +759,9 @@ public abstract class ClassUtils { @@ -759,9 +759,9 @@ public abstract class ClassUtils {
* conflicting method signatures (or a similar constraint is violated)
* @see java.lang.reflect.Proxy#getProxyClass
*/
@SuppressWarnings("deprecation")
@SuppressWarnings("deprecation") // on JDK 9
public static Class<?> createCompositeInterface(Class<?>[] interfaces, @Nullable ClassLoader classLoader) {
Assert.notEmpty(interfaces, "Interfaces must not be empty");
Assert.notEmpty(interfaces, "Interface array must not be empty");
return Proxy.getProxyClass(classLoader, interfaces);
}

6
spring-core/src/main/java/org/springframework/util/UpdateMessageDigestInputStream.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2018 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.
@ -38,7 +38,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream { @@ -38,7 +38,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
*/
public void updateMessageDigest(MessageDigest messageDigest) throws IOException {
int data;
while ((data = read()) != -1){
while ((data = read()) != -1) {
messageDigest.update((byte) data);
}
}
@ -54,7 +54,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream { @@ -54,7 +54,7 @@ abstract class UpdateMessageDigestInputStream extends InputStream {
public void updateMessageDigest(MessageDigest messageDigest, int len) throws IOException {
int data;
int bytesRead = 0;
while (bytesRead < len && (data = read()) != -1){
while (bytesRead < len && (data = read()) != -1) {
messageDigest.update((byte) data);
bytesRead++;
}

Loading…
Cancel
Save