diff --git a/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java b/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java index e64227fdd353..d921a33ada7e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java +++ b/spring-beans/src/main/java/org/springframework/beans/PropertyValue.java @@ -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. @@ -169,7 +169,7 @@ public synchronized boolean isConverted() { } /** - * 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 synchronized void setConvertedValue(@Nullable Object value) { } /** - * Return the converted value of the constructor argument, + * Return the converted value of this property value, * after processed type conversion. */ @Nullable diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java b/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java index 39497f5f07ff..744168742207 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/InjectionPoint.java @@ -180,7 +180,7 @@ public boolean equals(Object other) { if (this == other) { return true; } - if (getClass() != other.getClass()) { + if (other == null || getClass() != other.getClass()) { return false; } InjectionPoint otherPoint = (InjectionPoint) other; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionVisitor.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionVisitor.java index 6e71a0572e5e..a0fae36c9b74 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionVisitor.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/BeanDefinitionVisitor.java @@ -234,7 +234,7 @@ protected void visitArray(Object[] arrayVal) { } } - @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 @@ protected void visitList(List listVal) { } } - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) protected void visitSet(Set setVal) { Set newContent = new LinkedHashSet(); boolean entriesModified = false; @@ -262,7 +262,7 @@ protected void visitSet(Set setVal) { } } - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) protected void visitMap(Map mapVal) { Map newContent = new LinkedHashMap(); boolean entriesModified = false; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java index 2f685984fbc6..ec8aa5c140ea 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/RuntimeBeanReference.java @@ -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 @@ * @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 RuntimeBeanReference(String beanName) { /** * 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 String getBeanName() { } /** - * 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; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java index 1e20063cccfb..bc77a9f7c134 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlMapFactoryBean.java @@ -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 getObjectType() { * case of a shared singleton; else, on each {@link #getObject()} call. *

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 createMap() { Map result = new LinkedHashMap<>(); @@ -125,7 +125,7 @@ protected Map createMap() { return result; } - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) private void merge(Map output, Map map) { map.forEach((key, value) -> { Object existing = output.get(key); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.java b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.java index 200f78c4c9f4..71088f17f09c 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.java @@ -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 getObjectType() { *

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(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java index f28218afd8a0..4a10cdb15552 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanDefinition.java @@ -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; diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java index 640e712e8947..e6fcceb9e494 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java @@ -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. @@ -1648,7 +1648,7 @@ protected Object getObjectForBeanInstance( return beanInstance; } if (!(beanInstance instanceof FactoryBean)) { - throw new BeanIsNotAFactoryException(transformedBeanName(name), beanInstance.getClass()); + throw new BeanIsNotAFactoryException(beanName, beanInstance.getClass()); } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java index 2b04fb155e82..cfddff43e091 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionBuilder.java @@ -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,6 +180,8 @@ public BeanDefinitionBuilder setFactoryMethod(String factoryMethod) { /** * 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 BeanDefinitionBuilder addConstructorArgReference(String beanName) { } /** - * 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); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java index 776a610ea05f..e3e778010505 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java @@ -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. @@ -385,8 +385,7 @@ private Object resolveReference(Object argName, RuntimeBeanReference ref) { 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 @@ private Object resolveManagedArray(Object argName, List ml, Class elementT private List resolveManagedList(Object argName, List ml) { List 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; } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java index 6e874eb5511a..60e8a116728e 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/CglibSubclassingInstantiationStrategy.java @@ -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. @@ -176,7 +176,7 @@ public RootBeanDefinition getBeanDefinition() { @Override public boolean equals(Object other) { - return (getClass() == other.getClass() && + return (other != null && getClass() == other.getClass() && this.beanDefinition.equals(((CglibIdentitySupport) other).beanDefinition)); } diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java index c9d347e28bc1..243cf0754093 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/BeanDefinitionBuilderTests.java @@ -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.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 void beanClassWithSimpleProperty() { 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(); diff --git a/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java b/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java index 3425c433891a..1e83a21a13ce 100644 --- a/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java +++ b/spring-beans/src/test/java/org/springframework/tests/sample/beans/TestBean.java @@ -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; diff --git a/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java b/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java index 952113e88f9b..34ae5372d45e 100644 --- a/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java +++ b/spring-context/src/main/java/org/springframework/context/event/SimpleApplicationEventMulticaster.java @@ -166,7 +166,7 @@ protected void invokeListener(ApplicationListener listener, ApplicationEvent } } - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) private void doInvokeListener(ApplicationListener listener, ApplicationEvent event) { try { listener.onApplicationEvent(event); diff --git a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java b/spring-core/src/main/java/org/springframework/core/CollectionFactory.java index 4923464910d0..80cbb3df9135 100644 --- a/spring-core/src/main/java/org/springframework/core/CollectionFactory.java +++ b/spring-core/src/main/java/org/springframework/core/CollectionFactory.java @@ -241,7 +241,7 @@ public static boolean isApproximableMapType(@Nullable Class mapType) { * @see java.util.TreeMap * @see java.util.LinkedHashMap */ - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) public static Map createApproximateMap(@Nullable Object map, int capacity) { if (map instanceof EnumMap) { EnumMap enumMap = new EnumMap((EnumMap) map); @@ -294,7 +294,7 @@ public static Map createMap(Class mapType, int capacity) { * {@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 Map createMap(Class mapType, @Nullable Class keyType, int capacity) { Assert.notNull(mapType, "Map type must not be null"); if (mapType.isInterface()) { diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/IntegerToEnumConverterFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/IntegerToEnumConverterFactory.java index 8d56edee3f9a..e05bfe34c594 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/IntegerToEnumConverterFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/IntegerToEnumConverterFactory.java @@ -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 @@ * @author Stephane Nicoll * @since 4.3 */ -@SuppressWarnings({"unchecked", "rawtypes"}) +@SuppressWarnings({"rawtypes", "unchecked"}) final class IntegerToEnumConverterFactory implements ConverterFactory { @Override diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java index 5e45e62d484c..e79f62dccd1e 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToEnumConverterFactory.java @@ -26,7 +26,7 @@ * @author Stephane Nicoll * @since 3.0 */ -@SuppressWarnings({"unchecked", "rawtypes"}) +@SuppressWarnings({"rawtypes", "unchecked"}) final class StringToEnumConverterFactory implements ConverterFactory { @Override diff --git a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java index 1d69b41ac4fa..e13e03ed0f9b 100644 --- a/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java @@ -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. @@ -383,7 +383,7 @@ public MutablePropertySources getPropertySources() { } @Override - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) public Map getSystemProperties() { try { return (Map) System.getProperties(); @@ -409,7 +409,7 @@ protected String getSystemAttribute(String attributeName) { } @Override - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) public Map getSystemEnvironment() { if (suppressGetenvAccess()) { return Collections.emptyMap(); diff --git a/spring-core/src/main/java/org/springframework/core/env/StandardEnvironment.java b/spring-core/src/main/java/org/springframework/core/env/StandardEnvironment.java index 179e1d7b5a94..fc4570684d9d 100644 --- a/spring-core/src/main/java/org/springframework/core/env/StandardEnvironment.java +++ b/spring-core/src/main/java/org/springframework/core/env/StandardEnvironment.java @@ -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. @@ -75,8 +75,10 @@ public class StandardEnvironment extends AbstractEnvironment { */ @Override protected void customizePropertySources(MutablePropertySources propertySources) { - propertySources.addLast(new MapPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, getSystemProperties())); - propertySources.addLast(new SystemEnvironmentPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment())); + propertySources.addLast( + new PropertiesPropertySource(SYSTEM_PROPERTIES_PROPERTY_SOURCE_NAME, getSystemProperties())); + propertySources.addLast( + new SystemEnvironmentPropertySource(SYSTEM_ENVIRONMENT_PROPERTY_SOURCE_NAME, getSystemEnvironment())); } } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeCode.java b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeCode.java index 8a252f930901..aabc43d0b22e 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeCode.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/ast/TypeCode.java @@ -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. @@ -84,10 +84,9 @@ public Class getType() { 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]; } } diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java index 667e4c18b80c..82a307f6b9c2 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectiveConstructorResolver.java @@ -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 ConstructorExecutor resolve(EvaluationContext context, String typeName, L 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; diff --git a/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java b/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java index 94b5b25d57d6..e2e6d11c7f94 100644 --- a/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java +++ b/spring-expression/src/main/java/org/springframework/expression/spel/support/StandardTypeComparator.java @@ -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. @@ -83,20 +83,16 @@ else if (leftNumber instanceof BigInteger || rightNumber instanceof BigInteger) 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 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 leftNumber.byteValue() - rightNumber.byteValue(); } else { // Unknown Number subtypes -> best guess is double multiplication @@ -116,21 +112,4 @@ else if (leftNumber instanceof Byte || rightNumber instanceof Byte) { 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; - } - } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java b/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java index 3e18a956cb81..9830abdafe60 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/core/PreparedStatementCreatorFactory.java @@ -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. @@ -272,7 +272,7 @@ public void setValues(PreparedStatement ps) throws SQLException { 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); } diff --git a/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java b/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java index a5fba5a00dc1..80954b687827 100644 --- a/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java +++ b/spring-jms/src/main/java/org/springframework/jms/support/SimpleJmsHeaderMapper.java @@ -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 void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) { logger.debug("Failed to set JMSType - skipping", ex); } } - Set headerNames = headers.keySet(); - for (String headerName : headerNames) { + Set> entries = headers.entrySet(); + for (Map.Entry 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); diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java index c639ef71e256..9a205249586f 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java @@ -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 void remove(MergedContextConfiguration key, @Nullable HierarchyMode hiera } // 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> entry : this.hierarchyMap.entrySet()) { + if (entry.getValue().isEmpty()) { + this.hierarchyMap.remove(entry.getKey()); } } } diff --git a/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java b/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java index e7456f3f9aa5..f3415671bf09 100644 --- a/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java +++ b/spring-test/src/main/java/org/springframework/test/web/ModelAndViewAssert.java @@ -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. @@ -142,7 +142,7 @@ public static void assertModelAttributeValues(ModelAndView mav, Map callable, Object... processingContext) throws Exception { Assert.notNull(callable, "Callable must not be null"); startCallableProcessing(new WebAsyncTask(callable), processingContext); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/MapMethodProcessor.java b/spring-web/src/main/java/org/springframework/web/method/annotation/MapMethodProcessor.java index a9f921ced573..ea505d276bb2 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/MapMethodProcessor.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/MapMethodProcessor.java @@ -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 boolean supportsReturnType(MethodParameter returnType) { } @Override - @SuppressWarnings({"unchecked", "rawtypes"}) + @SuppressWarnings({"rawtypes", "unchecked"}) public void handleReturnValue(@Nullable Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception { diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandler.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandler.java index 287abc112eed..9acbe85ec0ff 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandler.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/SessionAttributesHandler.java @@ -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 @@ public Map retrieveAttributes(WebSession session) { * @param attributes candidate attributes for session storage */ public void storeAttributes(WebSession session, Map 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); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java index 77313e7cee49..15dbca40efed 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/RedirectView.java @@ -390,7 +390,7 @@ protected StringBuilder replaceUriTemplateVariables( result.append(UriUtils.encodePathSegment(value.toString(), encodingScheme)); endLastMatch = matcher.end(); } - result.append(targetUrl.substring(endLastMatch, targetUrl.length())); + result.append(targetUrl.substring(endLastMatch)); return result; }