diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 4101865e3b..58ee2b2ddd 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -419,7 +419,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); // Only check bean definition if it is complete. if (!mbd.isAbstract() && (allowEagerInit || - ((mbd.hasBeanClass() || !mbd.isLazyInit() || isAllowEagerClassLoading())) && + (mbd.hasBeanClass() || !mbd.isLazyInit() || isAllowEagerClassLoading()) && !requiresEagerInitForType(mbd.getFactoryBeanName()))) { // In case of FactoryBean, match object created by FactoryBean. boolean isFactoryBean = isFactoryBean(beanName, mbd); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java index 89b1726d32..64d429c462 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java @@ -402,8 +402,8 @@ public class BeanDefinitionParserDelegate { public BeanDefinitionDefaults getBeanDefinitionDefaults() { BeanDefinitionDefaults bdd = new BeanDefinitionDefaults(); bdd.setLazyInit("TRUE".equalsIgnoreCase(this.defaults.getLazyInit())); - bdd.setDependencyCheck(this.getDependencyCheck(DEFAULT_VALUE)); - bdd.setAutowireMode(this.getAutowireMode(DEFAULT_VALUE)); + bdd.setDependencyCheck(getDependencyCheck(DEFAULT_VALUE)); + bdd.setAutowireMode(getAutowireMode(DEFAULT_VALUE)); bdd.setInitMethodName(this.defaults.getInitMethod()); bdd.setDestroyMethodName(this.defaults.getDestroyMethod()); return bdd; @@ -1255,7 +1255,7 @@ public class BeanDefinitionParserDelegate { boolean hasKeyAttribute = entryEle.hasAttribute(KEY_ATTRIBUTE); boolean hasKeyRefAttribute = entryEle.hasAttribute(KEY_REF_ATTRIBUTE); if ((hasKeyAttribute && hasKeyRefAttribute) || - ((hasKeyAttribute || hasKeyRefAttribute)) && keyEle != null) { + (hasKeyAttribute || hasKeyRefAttribute) && keyEle != null) { error(" element is only allowed to contain either " + "a 'key' attribute OR a 'key-ref' attribute OR a sub-element", entryEle); } @@ -1284,7 +1284,7 @@ public class BeanDefinitionParserDelegate { boolean hasValueRefAttribute = entryEle.hasAttribute(VALUE_REF_ATTRIBUTE); boolean hasValueTypeAttribute = entryEle.hasAttribute(VALUE_TYPE_ATTRIBUTE); if ((hasValueAttribute && hasValueRefAttribute) || - ((hasValueAttribute || hasValueRefAttribute)) && valueEle != null) { + (hasValueAttribute || hasValueRefAttribute) && valueEle != null) { error(" element is only allowed to contain either " + "'value' attribute OR 'value-ref' attribute OR sub-element", entryEle); } diff --git a/spring-core/src/main/java/org/springframework/core/ResolvableType.java b/spring-core/src/main/java/org/springframework/core/ResolvableType.java index 35e6da4df8..c50d35f7a2 100644 --- a/spring-core/src/main/java/org/springframework/core/ResolvableType.java +++ b/spring-core/src/main/java/org/springframework/core/ResolvableType.java @@ -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. @@ -355,7 +355,7 @@ public class ResolvableType implements Serializable { if (this == NONE) { return false; } - return (((this.type instanceof Class && ((Class) this.type).isArray())) || + return ((this.type instanceof Class && ((Class) this.type).isArray()) || this.type instanceof GenericArrayType || resolveType().isArray()); } @@ -1427,8 +1427,9 @@ public class ResolvableType implements Serializable { @Override public ResolvableType resolveVariable(TypeVariable variable) { for (int i = 0; i < this.variables.length; i++) { - if (SerializableTypeWrapper.unwrap(this.variables[i]).equals( - SerializableTypeWrapper.unwrap(variable))) { + TypeVariable v1 = SerializableTypeWrapper.unwrap(this.variables[i]); + TypeVariable v2 = SerializableTypeWrapper.unwrap(variable); + if (ObjectUtils.nullSafeEquals(v1, v2)) { return this.generics[i]; } } diff --git a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java index 88f65e0bd5..21e8af6fae 100644 --- a/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java +++ b/spring-oxm/src/main/java/org/springframework/oxm/jaxb/Jaxb2Marshaller.java @@ -584,7 +584,7 @@ public class Jaxb2Marshaller implements MimeMarshaller, MimeUnmarshaller, Generi Type typeArgument = parameterizedType.getActualTypeArguments()[0]; if (typeArgument instanceof Class) { Class classArgument = (Class) typeArgument; - return (((classArgument.isArray() && Byte.TYPE == classArgument.getComponentType())) || + return ((classArgument.isArray() && Byte.TYPE == classArgument.getComponentType()) || isPrimitiveWrapper(classArgument) || isStandardClass(classArgument) || supportsInternal(classArgument, false)); } diff --git a/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java b/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java index aa6420d4b7..77cb08d064 100644 --- a/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java +++ b/spring-test/src/main/java/org/springframework/test/context/support/ApplicationContextInitializerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2014 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. @@ -17,7 +17,7 @@ package org.springframework.test.context.support; import java.util.Arrays; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -31,8 +31,8 @@ import org.springframework.test.context.ContextConfigurationAttributes; import org.springframework.util.Assert; /** - * Utility methods for working with {@link ApplicationContextInitializer - * ApplicationContextInitializers}. + * Utility methods for working with + * {@link ApplicationContextInitializer ApplicationContextInitializers}. * *

Although {@code ApplicationContextInitializerUtils} was first introduced * in Spring Framework 4.1, the initial implementations of methods in this class @@ -47,21 +47,15 @@ abstract class ApplicationContextInitializerUtils { private static final Log logger = LogFactory.getLog(ApplicationContextInitializerUtils.class); - private ApplicationContextInitializerUtils() { - /* no-op */ - } - /** * Resolve the set of merged {@code ApplicationContextInitializer} classes for the * supplied list of {@code ContextConfigurationAttributes}. - * *

Note that the {@link ContextConfiguration#inheritInitializers inheritInitializers} * flag of {@link ContextConfiguration @ContextConfiguration} will be taken into * consideration. Specifically, if the {@code inheritInitializers} flag is set to * {@code true} for a given level in the class hierarchy represented by the provided * configuration attributes, context initializer classes defined at the given level * will be merged with those defined in higher levels of the class hierarchy. - * * @param configAttributesList the list of configuration attributes to process; must * not be {@code null} or empty; must be ordered bottom-up * (i.e., as if we were traversing up the class hierarchy) @@ -71,19 +65,16 @@ abstract class ApplicationContextInitializerUtils { */ static Set>> resolveInitializerClasses( List configAttributesList) { - Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be empty"); - final Set>> initializerClasses = // - new HashSet>>(); + Assert.notEmpty(configAttributesList, "ContextConfigurationAttributes list must not be empty"); + Set>> initializerClasses = + new LinkedHashSet>>(); for (ContextConfigurationAttributes configAttributes : configAttributesList) { if (logger.isTraceEnabled()) { - logger.trace(String.format("Processing context initializers for context configuration attributes %s", - configAttributes)); + logger.trace("Processing context initializers for configuration attributes " + configAttributes); } - initializerClasses.addAll(Arrays.asList(configAttributes.getInitializers())); - if (!configAttributes.isInheritInitializers()) { break; } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java index 28f9f0b4fa..903cecb77e 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/HostRequestMatcher.java @@ -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. @@ -68,6 +68,7 @@ public final class HostRequestMatcher implements WebRequestMatcher { this.hosts.addAll(Arrays.asList(hosts)); } + @Override public boolean matches(WebRequest request) { URL url = request.getUrl(); diff --git a/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java b/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java index a3c72bcd63..445f4234b3 100644 --- a/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java +++ b/spring-web/src/main/java/org/springframework/web/method/annotation/SessionAttributesHandler.java @@ -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,9 +59,9 @@ public class SessionAttributesHandler { /** - * Create a new instance for a controller type. Session attribute names and - * types are extracted from the {@code @SessionAttributes} annotation, if - * present, on the given type. + * Create a new session attributes handler. Session attribute names and types + * are extracted from the {@code @SessionAttributes} annotation, if present, + * on the given type. * @param handlerType the controller type * @param sessionAttributeStore used for session access */ @@ -69,15 +69,15 @@ public class SessionAttributesHandler { Assert.notNull(sessionAttributeStore, "SessionAttributeStore may not be null"); this.sessionAttributeStore = sessionAttributeStore; - SessionAttributes annotation = - AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class); - if (annotation != null) { - this.attributeNames.addAll(Arrays.asList(annotation.names())); - this.attributeTypes.addAll(Arrays.asList(annotation.types())); + SessionAttributes ann = AnnotatedElementUtils.findMergedAnnotation(handlerType, SessionAttributes.class); + if (ann != null) { + this.attributeNames.addAll(Arrays.asList(ann.names())); + this.attributeTypes.addAll(Arrays.asList(ann.types())); } this.knownAttributeNames.addAll(this.attributeNames); } + /** * Whether the controller represented by this instance has declared any * session attributes through an {@link SessionAttributes} annotation.