Polishing

(cherry picked from commit 40efcc9)
This commit is contained in:
Juergen Hoeller
2018-06-28 14:51:31 +02:00
parent 3e64388b20
commit a631af80c1
113 changed files with 648 additions and 693 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 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.
@@ -32,9 +32,12 @@ import org.springframework.util.StringUtils;
@SuppressWarnings("serial")
public class SimpleKey implements Serializable {
/** An empty key. */
public static final SimpleKey EMPTY = new SimpleKey();
private final Object[] params;
private final int hashCode;
@@ -49,10 +52,11 @@ public class SimpleKey implements Serializable {
this.hashCode = Arrays.deepHashCode(this.params);
}
@Override
public boolean equals(Object obj) {
return (this == obj || (obj instanceof SimpleKey
&& Arrays.deepEquals(this.params, ((SimpleKey) obj).params)));
public boolean equals(Object other) {
return (this == other ||
(other instanceof SimpleKey && Arrays.deepEquals(this.params, ((SimpleKey) other).params)));
}
@Override

View File

@@ -54,8 +54,8 @@ import org.springframework.util.ClassUtils;
* @author Stephane Nicoll
* @since 2.5
* @see ContextAnnotationAutowireCandidateResolver
* @see CommonAnnotationBeanPostProcessor
* @see ConfigurationClassPostProcessor
* @see CommonAnnotationBeanPostProcessor
* @see org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor
* @see org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor
* @see org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor
@@ -103,7 +103,6 @@ public class AnnotationConfigUtils {
public static final String PERSISTENCE_ANNOTATION_PROCESSOR_BEAN_NAME =
"org.springframework.context.annotation.internalPersistenceAnnotationProcessor";
private static final String PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME =
"org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor";

View File

@@ -553,16 +553,15 @@ class ConfigurationClassParser {
for (DeferredImportSelectorHolder deferredImport : deferredImports) {
Class<? extends Group> group = deferredImport.getImportSelector().getImportGroup();
DeferredImportSelectorGrouping grouping = groupings.computeIfAbsent(
(group == null ? deferredImport : group),
(key) -> new DeferredImportSelectorGrouping(createGroup(group)));
(group != null ? group : deferredImport),
key -> new DeferredImportSelectorGrouping(createGroup(group)));
grouping.add(deferredImport);
configurationClasses.put(deferredImport.getConfigurationClass().getMetadata(),
deferredImport.getConfigurationClass());
}
for (DeferredImportSelectorGrouping grouping : groupings.values()) {
grouping.getImports().forEach((entry) -> {
ConfigurationClass configurationClass = configurationClasses.get(
entry.getMetadata());
grouping.getImports().forEach(entry -> {
ConfigurationClass configurationClass = configurationClasses.get(entry.getMetadata());
try {
processImports(configurationClass, asSourceClass(configurationClass),
asSourceClasses(entry.getImportClassName()), false);
@@ -573,15 +572,14 @@ class ConfigurationClassParser {
catch (Throwable ex) {
throw new BeanDefinitionStoreException(
"Failed to process import candidates for configuration class [" +
configurationClass.getMetadata().getClassName() + "]", ex);
configurationClass.getMetadata().getClassName() + "]", ex);
}
});
}
}
private Group createGroup(@Nullable Class<? extends Group> type) {
Class<? extends Group> effectiveType = (type != null ? type
: DefaultDeferredImportSelectorGroup.class);
Class<? extends Group> effectiveType = (type != null ? type : DefaultDeferredImportSelectorGroup.class);
Group group = BeanUtils.instantiateClass(effectiveType);
ParserStrategyUtils.invokeAwareMethods(group,
ConfigurationClassParser.this.environment,
@@ -705,7 +703,7 @@ class ConfigurationClassParser {
}
/**
* Factory method to obtain {@link SourceClass}s from class names.
* Factory method to obtain {@link SourceClass SourceClasss} from class names.
*/
private Collection<SourceClass> asSourceClasses(String... classNames) throws IOException {
List<SourceClass> annotatedClasses = new ArrayList<>(classNames.length);

View File

@@ -1252,8 +1252,8 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
*/
@Nullable
protected BeanFactory getInternalParentBeanFactory() {
return (getParent() instanceof ConfigurableApplicationContext) ?
((ConfigurableApplicationContext) getParent()).getBeanFactory() : getParent();
return (getParent() instanceof ConfigurableApplicationContext ?
((ConfigurableApplicationContext) getParent()).getBeanFactory() : getParent());
}
@@ -1295,8 +1295,8 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
*/
@Nullable
protected MessageSource getInternalParentMessageSource() {
return (getParent() instanceof AbstractApplicationContext) ?
((AbstractApplicationContext) getParent()).messageSource : getParent();
return (getParent() instanceof AbstractApplicationContext ?
((AbstractApplicationContext) getParent()).messageSource : getParent());
}

View File

@@ -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.
@@ -143,8 +143,9 @@ public abstract class AbstractRefreshableApplicationContext extends AbstractAppl
@Override
protected void cancelRefresh(BeansException ex) {
synchronized (this.beanFactoryMonitor) {
if (this.beanFactory != null)
if (this.beanFactory != null) {
this.beanFactory.setSerializationId(null);
}
}
super.cancelRefresh(ex);
}

View File

@@ -144,16 +144,16 @@ public class PeriodicTrigger implements Trigger {
@Override
public boolean equals(Object obj) {
if (this == obj) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(obj instanceof PeriodicTrigger)) {
if (!(other instanceof PeriodicTrigger)) {
return false;
}
PeriodicTrigger other = (PeriodicTrigger) obj;
return (this.fixedRate == other.fixedRate && this.initialDelay == other.initialDelay &&
this.period == other.period);
PeriodicTrigger otherTrigger = (PeriodicTrigger) other;
return (this.fixedRate == otherTrigger.fixedRate && this.initialDelay == otherTrigger.initialDelay &&
this.period == otherTrigger.period);
}
@Override

View File

@@ -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.
@@ -38,21 +38,40 @@ public class ScheduledMethodRunnable implements Runnable {
private final Method method;
/**
* Create a {@code ScheduledMethodRunnable} for the given target instance,
* calling the specified method.
* @param target the target instance to call the method on
* @param method the target method to call
*/
public ScheduledMethodRunnable(Object target, Method method) {
this.target = target;
this.method = method;
}
/**
* Create a {@code ScheduledMethodRunnable} for the given target instance,
* calling the specified method by name.
* @param target the target instance to call the method on
* @param methodName the name of the target method
* @throws NoSuchMethodException if the specified method does not exist
*/
public ScheduledMethodRunnable(Object target, String methodName) throws NoSuchMethodException {
this.target = target;
this.method = target.getClass().getMethod(methodName);
}
/**
* Return the target instance to call the method on.
*/
public Object getTarget() {
return this.target;
}
/**
* Return the target method to call.
*/
public Method getMethod() {
return this.method;
}

View File

@@ -136,8 +136,8 @@ import org.springframework.util.StringUtils;
* @author Mark Fisher
* @since 2.0
*/
public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProcessorAdapter implements
BeanClassLoaderAware, BeanFactoryAware, ResourceLoaderAware, DisposableBean, Ordered {
public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProcessorAdapter
implements BeanClassLoaderAware, BeanFactoryAware, ResourceLoaderAware, DisposableBean, Ordered {
/**
* The {@link org.springframework.core.io.Resource}-style prefix that denotes
@@ -275,8 +275,8 @@ public class ScriptFactoryPostProcessor extends InstantiationAwareBeanPostProces
if (ex instanceof BeanCreationException &&
((BeanCreationException) ex).getMostSpecificCause() instanceof BeanCurrentlyInCreationException) {
if (logger.isTraceEnabled()) {
logger.trace("Could not determine scripted object type for bean '" + beanName + "': "
+ ex.getMessage());
logger.trace("Could not determine scripted object type for bean '" + beanName + "': " +
ex.getMessage());
}
}
else {

View File

@@ -715,8 +715,8 @@ public class DataBinder implements PropertyEditorRegistry, TypeConverter {
* @see #doBind(org.springframework.beans.MutablePropertyValues)
*/
public void bind(PropertyValues pvs) {
MutablePropertyValues mpvs = (pvs instanceof MutablePropertyValues) ?
(MutablePropertyValues) pvs : new MutablePropertyValues(pvs);
MutablePropertyValues mpvs = (pvs instanceof MutablePropertyValues ?
(MutablePropertyValues) pvs : new MutablePropertyValues(pvs));
doBind(mpvs);
}