Polishing

This commit is contained in:
Juergen Hoeller
2019-06-12 00:51:09 +02:00
parent bb7096b024
commit 8d5c36269e
31 changed files with 143 additions and 159 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -169,7 +169,7 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
}
/**
* Set the converted value of the constructor argument,
* Set the converted value of this property value,
* after processed type conversion.
*/
public synchronized void setConvertedValue(@Nullable Object value) {
@@ -178,7 +178,7 @@ public class PropertyValue extends BeanMetadataAttributeAccessor implements Seri
}
/**
* Return the converted value of the constructor argument,
* Return the converted value of this property value,
* after processed type conversion.
*/
@Nullable

View File

@@ -180,7 +180,7 @@ public class InjectionPoint {
if (this == other) {
return true;
}
if (getClass() != other.getClass()) {
if (other == null || getClass() != other.getClass()) {
return false;
}
InjectionPoint otherPoint = (InjectionPoint) other;

View File

@@ -234,7 +234,7 @@ public class BeanDefinitionVisitor {
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
protected void visitList(List listVal) {
for (int i = 0; i < listVal.size(); i++) {
Object elem = listVal.get(i);
@@ -245,7 +245,7 @@ public class BeanDefinitionVisitor {
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
protected void visitSet(Set setVal) {
Set newContent = new LinkedHashSet();
boolean entriesModified = false;
@@ -262,7 +262,7 @@ public class BeanDefinitionVisitor {
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
protected void visitMap(Map<?, ?> mapVal) {
Map newContent = new LinkedHashMap();
boolean entriesModified = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -26,7 +26,7 @@ import org.springframework.util.Assert;
* @author Rod Johnson
* @author Juergen Hoeller
* @see BeanDefinition#getPropertyValues()
* @see org.springframework.beans.factory.BeanFactory#getBean
* @see org.springframework.beans.factory.BeanFactory#getBean(String)
*/
public class RuntimeBeanReference implements BeanReference {
@@ -39,9 +39,7 @@ public class RuntimeBeanReference implements BeanReference {
/**
* Create a new RuntimeBeanReference to the given bean name,
* without explicitly marking it as reference to a bean in
* the parent factory.
* Create a new RuntimeBeanReference to the given bean name.
* @param beanName name of the target bean
*/
public RuntimeBeanReference(String beanName) {
@@ -50,11 +48,10 @@ public class RuntimeBeanReference implements BeanReference {
/**
* Create a new RuntimeBeanReference to the given bean name,
* with the option to mark it as reference to a bean in
* the parent factory.
* with the option to mark it as reference to a bean in the parent factory.
* @param beanName name of the target bean
* @param toParent whether this is an explicit reference to
* a bean in the parent factory
* @param toParent whether this is an explicit reference to a bean in the
* parent factory
*/
public RuntimeBeanReference(String beanName, boolean toParent) {
Assert.hasText(beanName, "'beanName' must not be empty");
@@ -69,8 +66,7 @@ public class RuntimeBeanReference implements BeanReference {
}
/**
* Return whether this is an explicit reference to a bean
* in the parent factory.
* Return whether this is an explicit reference to a bean in the parent factory.
*/
public boolean isToParent() {
return this.toParent;

View File

@@ -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.
@@ -117,7 +117,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean<Map
* case of a shared singleton; else, on each {@link #getObject()} call.
* <p>The default implementation returns the merged {@code Map} instance.
* @return the object returned by this factory
* @see #process(java.util.Map, MatchCallback)
* @see #process(MatchCallback)
*/
protected Map<String, Object> createMap() {
Map<String, Object> result = new LinkedHashMap<>();
@@ -125,7 +125,7 @@ public class YamlMapFactoryBean extends YamlProcessor implements FactoryBean<Map
return result;
}
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
private void merge(Map<String, Object> output, Map<String, Object> map) {
map.forEach((key, value) -> {
Object existing = output.get(key);

View File

@@ -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.
@@ -128,7 +128,7 @@ public class YamlPropertiesFactoryBean extends YamlProcessor implements FactoryB
* <p>Invoked lazily the first time {@link #getObject()} is invoked in
* case of a shared singleton; else, on each {@link #getObject()} call.
* @return the object returned by this factory
* @see #process(MatchCallback) ()
* @see #process(MatchCallback)
*/
protected Properties createProperties() {
Properties result = CollectionFactory.createStringAdaptingProperties();

View File

@@ -65,7 +65,7 @@ public abstract class AbstractBeanDefinition extends BeanMetadataAttributeAccess
public static final String SCOPE_DEFAULT = "";
/**
* Constant that indicates no autowiring at all.
* Constant that indicates no external autowiring at all.
* @see #setAutowireMode
*/
public static final int AUTOWIRE_NO = AutowireCapableBeanFactory.AUTOWIRE_NO;

View File

@@ -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.
@@ -1628,7 +1628,7 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
return beanInstance;
}
if (!(beanInstance instanceof FactoryBean)) {
throw new BeanIsNotAFactoryException(transformedBeanName(name), beanInstance.getClass());
throw new BeanIsNotAFactoryException(beanName, beanInstance.getClass());
}
}

View File

@@ -180,6 +180,8 @@ public class BeanDefinitionBuilder {
/**
* Set the name of a non-static factory method to use for this definition,
* including the bean name of the factory instance to call the method on.
* @param factoryMethod the name of the factory method
* @param factoryBean the name of the bean to call the specified factory method on
* @since 4.3.6
*/
public BeanDefinitionBuilder setFactoryMethodOnBean(String factoryMethod, String factoryBean) {
@@ -209,7 +211,7 @@ public class BeanDefinitionBuilder {
}
/**
* Add the supplied property value under the given name.
* Add the supplied property value under the given property name.
*/
public BeanDefinitionBuilder addPropertyValue(String name, @Nullable Object value) {
this.beanDefinition.getPropertyValues().add(name, value);
@@ -278,7 +280,7 @@ public class BeanDefinitionBuilder {
}
/**
* Set the depency check mode for this definition.
* Set the dependency check mode for this definition.
*/
public BeanDefinitionBuilder setDependencyCheck(int dependencyCheck) {
this.beanDefinition.setDependencyCheck(dependencyCheck);

View File

@@ -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.
@@ -281,6 +281,40 @@ class BeanDefinitionValueResolver {
return value.resolveTargetType(this.beanFactory.getBeanClassLoader());
}
/**
* Resolve a reference to another bean in the factory.
*/
@Nullable
private Object resolveReference(Object argName, RuntimeBeanReference ref) {
try {
Object bean;
String refName = ref.getBeanName();
refName = String.valueOf(doEvaluate(refName));
if (ref.isToParent()) {
if (this.beanFactory.getParentBeanFactory() == null) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Can't resolve reference to bean '" + refName +
"' in parent factory: no parent factory available");
}
bean = this.beanFactory.getParentBeanFactory().getBean(refName);
}
else {
bean = this.beanFactory.getBean(refName);
this.beanFactory.registerDependentBean(refName, this.beanName);
}
if (bean instanceof NullBean) {
bean = null;
}
return bean;
}
catch (BeansException ex) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
}
}
/**
* Resolve an inner bean definition.
* @param argName the name of the argument that the inner bean is defined for
@@ -345,48 +379,13 @@ class BeanDefinitionValueResolver {
return actualInnerBeanName;
}
/**
* Resolve a reference to another bean in the factory.
*/
@Nullable
private Object resolveReference(Object argName, RuntimeBeanReference ref) {
try {
Object bean;
String refName = ref.getBeanName();
refName = String.valueOf(doEvaluate(refName));
if (ref.isToParent()) {
if (this.beanFactory.getParentBeanFactory() == null) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Can't resolve reference to bean '" + refName +
"' in parent factory: no parent factory available");
}
bean = this.beanFactory.getParentBeanFactory().getBean(refName);
}
else {
bean = this.beanFactory.getBean(refName);
this.beanFactory.registerDependentBean(refName, this.beanName);
}
if (bean instanceof NullBean) {
bean = null;
}
return bean;
}
catch (BeansException ex) {
throw new BeanCreationException(
this.beanDefinition.getResourceDescription(), this.beanName,
"Cannot resolve reference to bean '" + ref.getBeanName() + "' while setting " + argName, ex);
}
}
/**
* For each element in the managed array, resolve reference if necessary.
*/
private Object resolveManagedArray(Object argName, List<?> ml, Class<?> elementType) {
Object resolved = Array.newInstance(elementType, ml.size());
for (int i = 0; i < ml.size(); i++) {
Array.set(resolved, i,
resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
Array.set(resolved, i, resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
}
return resolved;
}
@@ -397,8 +396,7 @@ class BeanDefinitionValueResolver {
private List<?> resolveManagedList(Object argName, List<?> ml) {
List<Object> resolved = new ArrayList<>(ml.size());
for (int i = 0; i < ml.size(); i++) {
resolved.add(
resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
resolved.add(resolveValueIfNecessary(new KeyedArgName(argName, i), ml.get(i)));
}
return resolved;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -176,7 +176,7 @@ public class CglibSubclassingInstantiationStrategy extends SimpleInstantiationSt
@Override
public boolean equals(Object other) {
return (getClass() == other.getClass() &&
return (other != null && getClass() == other.getClass() &&
this.beanDefinition.equals(((CglibIdentitySupport) other).beanDefinition));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 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.
@@ -23,7 +23,9 @@ import org.junit.Test;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.tests.sample.beans.TestBean;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
* @author Rod Johnson
@@ -36,9 +38,9 @@ public class BeanDefinitionBuilderTests {
String[] dependsOn = new String[] { "A", "B", "C" };
BeanDefinitionBuilder bdb = BeanDefinitionBuilder.rootBeanDefinition(TestBean.class);
bdb.setScope(BeanDefinition.SCOPE_PROTOTYPE);
bdb.addPropertyReference("age", "15");
for (int i = 0; i < dependsOn.length; i++) {
bdb.addDependsOn(dependsOn[i]);
bdb.addPropertyValue("age", "15");
for (String dependsOnEntry : dependsOn) {
bdb.addDependsOn(dependsOnEntry);
}
RootBeanDefinition rbd = (RootBeanDefinition) bdb.getBeanDefinition();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 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.
@@ -61,8 +61,6 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
private ITestBean spouse;
protected ITestBean[] spouses;
private String touchy;
private String[] stringArray;

View File

@@ -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.
@@ -166,7 +166,7 @@ public class SimpleApplicationEventMulticaster extends AbstractApplicationEventM
}
}
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
private void doInvokeListener(ApplicationListener listener, ApplicationEvent event) {
try {
listener.onApplicationEvent(event);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -658,6 +658,9 @@ public class MBeanClientInterceptor
if (this == other) {
return true;
}
if (!(other instanceof MethodCacheKey)) {
return false;
}
MethodCacheKey otherKey = (MethodCacheKey) other;
return (this.name.equals(otherKey.name) && Arrays.equals(this.parameterTypes, otherKey.parameterTypes));
}

View File

@@ -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.
@@ -141,7 +141,7 @@ public abstract class CollectionFactory {
* Create the most appropriate collection for the given collection type.
* <p>Delegates to {@link #createCollection(Class, Class, int)} with a
* {@code null} element type.
* @param collectionType the desired type of the target collection; never {@code null}
* @param collectionType the desired type of the target collection (never {@code null})
* @param capacity the initial capacity
* @return a new collection instance
* @throws IllegalArgumentException if the supplied {@code collectionType}
@@ -160,7 +160,7 @@ public abstract class CollectionFactory {
* supplied {@code elementType} is an enum type matching type {@code E}.
* As an alternative, the caller may wish to treat the return value as a
* raw collection or collection of {@link Object}.
* @param collectionType the desired type of the target collection; never {@code null}
* @param collectionType the desired type of the target collection (never {@code null})
* @param elementType the collection's element type, or {@code null} if unknown
* (note: only relevant for {@link EnumSet} creation)
* @param capacity the initial capacity
@@ -237,7 +237,7 @@ public abstract class CollectionFactory {
* @see java.util.TreeMap
* @see java.util.LinkedHashMap
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
public static <K, V> Map<K, V> createApproximateMap(@Nullable Object map, int capacity) {
if (map instanceof EnumMap) {
EnumMap enumMap = new EnumMap((EnumMap) map);
@@ -276,7 +276,7 @@ public abstract class CollectionFactory {
* may wish to treat the return value as a raw map or map keyed by
* {@link Object}. Similarly, type safety cannot be enforced if the
* desired {@code mapType} is {@link MultiValueMap}.
* @param mapType the desired type of the target map; never {@code null}
* @param mapType the desired type of the target map (never {@code null})
* @param keyType the map's key type, or {@code null} if unknown
* (note: only relevant for {@link EnumMap} creation)
* @param capacity the initial capacity
@@ -290,7 +290,7 @@ public abstract class CollectionFactory {
* {@code null}; or if the desired {@code mapType} is {@link EnumMap} and
* the supplied {@code keyType} is not a subtype of {@link Enum}
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
public static <K, V> Map<K, V> createMap(Class<?> mapType, @Nullable Class<?> keyType, int capacity) {
Assert.notNull(mapType, "Map type must not be null");
if (mapType.isInterface()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 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.
@@ -26,7 +26,7 @@ import org.springframework.core.convert.converter.ConverterFactory;
* @author Stephane Nicoll
* @since 4.3
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
final class IntegerToEnumConverterFactory implements ConverterFactory<Integer, Enum> {
@Override
@@ -35,7 +35,7 @@ final class IntegerToEnumConverterFactory implements ConverterFactory<Integer, E
}
private class IntegerToEnum<T extends Enum> implements Converter<Integer, T> {
private static class IntegerToEnum<T extends Enum> implements Converter<Integer, T> {
private final Class<T> enumType;

View File

@@ -26,7 +26,7 @@ import org.springframework.core.convert.converter.ConverterFactory;
* @author Stephane Nicoll
* @since 3.0
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
final class StringToEnumConverterFactory implements ConverterFactory<String, Enum> {
@Override
@@ -35,7 +35,7 @@ final class StringToEnumConverterFactory implements ConverterFactory<String, Enu
}
private class StringToEnum<T extends Enum> implements Converter<String, T> {
private static class StringToEnum<T extends Enum> implements Converter<String, T> {
private final Class<T> enumType;

View File

@@ -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.
@@ -379,7 +379,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
public Map<String, Object> getSystemProperties() {
try {
return (Map) System.getProperties();
@@ -405,7 +405,7 @@ public abstract class AbstractEnvironment implements ConfigurableEnvironment {
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
public Map<String, Object> getSystemEnvironment() {
if (suppressGetenvAccess()) {
return Collections.emptyMap();

View File

@@ -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.
@@ -57,10 +57,9 @@ public enum TypeCode {
public static TypeCode forName(String name) {
String searchingFor = name.toUpperCase();
TypeCode[] tcs = values();
for (int i = 1; i < tcs.length; i++) {
if (tcs[i].name().equals(searchingFor)) {
if (tcs[i].name().equalsIgnoreCase(name)) {
return tcs[i];
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -62,7 +62,7 @@ public class ReflectiveConstructorResolver implements ConstructorResolver {
Arrays.sort(ctors, (c1, c2) -> {
int c1pl = c1.getParameterCount();
int c2pl = c2.getParameterCount();
return (c1pl < c2pl ? -1 : (c1pl > c2pl ? 1 : 0));
return Integer.compare(c1pl, c2pl);
});
Constructor<?> closeMatch = null;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 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.
@@ -26,8 +26,8 @@ import org.springframework.lang.Nullable;
import org.springframework.util.NumberUtils;
/**
* A simple basic {@link TypeComparator} implementation.
* It supports comparison of Numbers and types implementing Comparable.
* A basic {@link TypeComparator} implementation: supports comparison of
* {@link Number} types as well as types implementing {@link Comparable}.
*
* @author Andy Clement
* @author Juergen Hoeller
@@ -83,20 +83,16 @@ public class StandardTypeComparator implements TypeComparator {
return leftBigInteger.compareTo(rightBigInteger);
}
else if (leftNumber instanceof Long || rightNumber instanceof Long) {
// Don't call Long.compare here - only available on JDK 1.7+
return compare(leftNumber.longValue(), rightNumber.longValue());
return Long.compare(leftNumber.longValue(), rightNumber.longValue());
}
else if (leftNumber instanceof Integer || rightNumber instanceof Integer) {
// Don't call Integer.compare here - only available on JDK 1.7+
return compare(leftNumber.intValue(), rightNumber.intValue());
return Integer.compare(leftNumber.intValue(), rightNumber.intValue());
}
else if (leftNumber instanceof Short || rightNumber instanceof Short) {
// Don't call Short.compare here - only available on JDK 1.7+
return compare(leftNumber.shortValue(), rightNumber.shortValue());
return Short.compare(leftNumber.shortValue(), rightNumber.shortValue());
}
else if (leftNumber instanceof Byte || rightNumber instanceof Byte) {
// Don't call Short.compare here - only available on JDK 1.7+
return compare(leftNumber.byteValue(), rightNumber.byteValue());
return Byte.compare(leftNumber.byteValue(), rightNumber.byteValue());
}
else {
// Unknown Number subtypes -> best guess is double multiplication
@@ -116,21 +112,4 @@ public class StandardTypeComparator implements TypeComparator {
throw new SpelEvaluationException(SpelMessage.NOT_COMPARABLE, left.getClass(), right.getClass());
}
private static int compare(long x, long y) {
return (x < y ? -1 : (x > y ? 1 : 0));
}
private static int compare(int x, int y) {
return (x < y ? -1 : (x > y ? 1 : 0));
}
private static int compare(short x, short y) {
return x - y;
}
private static int compare(byte x, byte y) {
return x - y;
}
}

View File

@@ -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.
@@ -196,7 +196,7 @@ public class PreparedStatementCreatorFactory {
Assert.notNull(parameters, "Parameters List must not be null");
this.parameters = parameters;
if (this.parameters.size() != declaredParameters.size()) {
// account for named parameters being used multiple times
// Account for named parameters being used multiple times
Set<String> names = new HashSet<>();
for (int i = 0; i < parameters.size(); i++) {
Object param = parameters.get(i);
@@ -264,7 +264,7 @@ public class PreparedStatementCreatorFactory {
Collection<?> entries = (Collection<?>) in;
for (Object entry : entries) {
if (entry instanceof Object[]) {
Object[] valueArray = ((Object[])entry);
Object[] valueArray = (Object[]) entry;
for (Object argValue : valueArray) {
StatementCreatorUtils.setParameterValue(ps, sqlColIndx++, declaredParameter, argValue);
}

View File

@@ -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.
@@ -577,6 +577,9 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
if (this == other) {
return true;
}
if (!(other instanceof ConsumerCacheKey)) {
return false;
}
ConsumerCacheKey otherKey = (ConsumerCacheKey) other;
return (destinationEquals(otherKey) &&
ObjectUtils.nullSafeEquals(this.selector, otherKey.selector) &&
@@ -585,6 +588,11 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
this.durable == otherKey.durable);
}
@Override
public int hashCode() {
return 31 * super.hashCode() + ObjectUtils.nullSafeHashCode(this.selector);
}
@Override
public String toString() {
return super.toString() + " [selector=" + this.selector + ", noLocal=" + this.noLocal +

View File

@@ -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.
@@ -92,10 +92,11 @@ public class SimpleJmsHeaderMapper extends AbstractHeaderMapper<Message> impleme
logger.info("Failed to set JMSType - skipping", ex);
}
}
Set<String> headerNames = headers.keySet();
for (String headerName : headerNames) {
Set<Map.Entry<String, Object>> entries = headers.entrySet();
for (Map.Entry<String, Object> entry : entries) {
String headerName = entry.getKey();
if (StringUtils.hasText(headerName) && !headerName.startsWith(JmsHeaders.PREFIX)) {
Object value = headers.get(headerName);
Object value = entry.getValue();
if (value != null && SUPPORTED_PROPERTY_TYPES.contains(value.getClass())) {
try {
String propertyName = this.fromHeaderName(headerName);

View File

@@ -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.
@@ -180,9 +180,9 @@ public class DefaultContextCache implements ContextCache {
}
// Remove empty entries from the hierarchy map.
for (MergedContextConfiguration currentKey : this.hierarchyMap.keySet()) {
if (this.hierarchyMap.get(currentKey).isEmpty()) {
this.hierarchyMap.remove(currentKey);
for (Map.Entry<MergedContextConfiguration, Set<MergedContextConfiguration>> entry : this.hierarchyMap.entrySet()) {
if (entry.getValue().isEmpty()) {
this.hierarchyMap.remove(entry.getKey());
}
}
}

View File

@@ -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.
@@ -25,7 +25,8 @@ import java.util.Set;
import org.springframework.util.ObjectUtils;
import org.springframework.web.servlet.ModelAndView;
import static org.springframework.test.util.AssertionErrors.*;
import static org.springframework.test.util.AssertionErrors.assertTrue;
import static org.springframework.test.util.AssertionErrors.fail;
/**
* A collection of assertions intended to simplify testing scenarios dealing
@@ -47,7 +48,7 @@ public abstract class ModelAndViewAssert {
* Checks whether the model value under the given {@code modelName}
* exists and checks it type, based on the {@code expectedType}. If the
* model entry exists and the type matches, the model value is returned.
* @param mav ModelAndView to test against (never {@code null})
* @param mav the ModelAndView to test against (never {@code null})
* @param modelName name of the object to add to the model (never {@code null})
* @param expectedType expected type of the model value
* @return the model value
@@ -66,7 +67,7 @@ public abstract class ModelAndViewAssert {
/**
* Compare each individual entry in a list, without first sorting the lists.
* @param mav ModelAndView to test against (never {@code null})
* @param mav the ModelAndView to test against (never {@code null})
* @param modelName name of the object to add to the model (never {@code null})
* @param expectedList the expected list
*/
@@ -81,7 +82,7 @@ public abstract class ModelAndViewAssert {
/**
* Assert whether or not a model attribute is available.
* @param mav ModelAndView to test against (never {@code null})
* @param mav the ModelAndView to test against (never {@code null})
* @param modelName name of the object to add to the model (never {@code null})
*/
public static void assertModelAttributeAvailable(ModelAndView mav, String modelName) {
@@ -92,7 +93,7 @@ public abstract class ModelAndViewAssert {
/**
* Compare a given {@code expectedValue} to the value from the model
* bound under the given {@code modelName}.
* @param mav ModelAndView to test against (never {@code null})
* @param mav the ModelAndView to test against (never {@code null})
* @param modelName name of the object to add to the model (never {@code null})
* @param expectedValue the model value
*/
@@ -105,7 +106,7 @@ public abstract class ModelAndViewAssert {
/**
* Inspect the {@code expectedModel} to see if all elements in the
* model appear and are equal.
* @param mav ModelAndView to test against (never {@code null})
* @param mav the ModelAndView to test against (never {@code null})
* @param expectedModel the expected model
*/
public static void assertModelAttributeValues(ModelAndView mav, Map<String, Object> expectedModel) {
@@ -135,13 +136,13 @@ public abstract class ModelAndViewAssert {
/**
* Compare each individual entry in a list after having sorted both lists
* (optionally using a comparator).
* @param mav ModelAndView to test against (never {@code null})
* @param mav the ModelAndView to test against (never {@code null})
* @param modelName name of the object to add to the model (never {@code null})
* @param expectedList the expected list
* @param comparator the comparator to use (may be {@code null}). If not
* specifying the comparator, both lists will be sorted not using any comparator.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
public static void assertSortAndCompareListModelAttribute(
ModelAndView mav, String modelName, List expectedList, Comparator comparator) {
@@ -159,7 +160,7 @@ public abstract class ModelAndViewAssert {
/**
* Check to see if the view name in the ModelAndView matches the given
* {@code expectedName}.
* @param mav ModelAndView to test against (never {@code null})
* @param mav the ModelAndView to test against (never {@code null})
* @param expectedName the name of the model value
*/
public static void assertViewName(ModelAndView mav, String expectedName) {

View File

@@ -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.
@@ -256,7 +256,7 @@ public final class WebAsyncManager {
* @see #getConcurrentResult()
* @see #getConcurrentResultContext()
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
public void startCallableProcessing(Callable<?> callable, Object... processingContext) throws Exception {
Assert.notNull(callable, "Callable must not be null");
startCallableProcessing(new WebAsyncTask(callable), processingContext);
@@ -342,7 +342,6 @@ public final class WebAsyncManager {
}
}
@SuppressWarnings("ConstantConditions")
private void logExecutorWarning() {
if (taskExecutorWarning && logger.isWarnEnabled()) {
synchronized (DEFAULT_TASK_EXECUTOR) {
@@ -368,7 +367,6 @@ public final class WebAsyncManager {
return request != null ? request.getRequestURI() : "servlet container";
}
private void setConcurrentResultAndDispatch(Object result) {
synchronized (WebAsyncManager.this) {
if (this.concurrentResult != RESULT_NONE) {

View File

@@ -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.
@@ -60,7 +60,7 @@ public class MapMethodProcessor implements HandlerMethodArgumentResolver, Handle
}
@Override
@SuppressWarnings({"unchecked", "rawtypes"})
@SuppressWarnings({"rawtypes", "unchecked"})
public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType,
ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {

View File

@@ -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.
@@ -113,8 +113,7 @@ class SessionAttributesHandler {
* @param attributes candidate attributes for session storage
*/
public void storeAttributes(WebSession session, Map<String, ?> attributes) {
attributes.keySet().forEach(name -> {
Object value = attributes.get(name);
attributes.forEach((name, value) -> {
if (value != null && isHandlerSessionAttribute(name, value.getClass())) {
session.getAttributes().put(name, value);
}

View File

@@ -390,7 +390,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
result.append(UriUtils.encodePathSegment(value.toString(), encodingScheme));
endLastMatch = matcher.end();
}
result.append(targetUrl.substring(endLastMatch, targetUrl.length()));
result.append(targetUrl.substring(endLastMatch));
return result;
}