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 1862137dc05..3b533c4f000 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 @@ -813,22 +813,22 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } else if (oldBeanDefinition.getRole() < beanDefinition.getRole()) { // e.g. was ROLE_APPLICATION, now overriding with ROLE_SUPPORT or ROLE_INFRASTRUCTURE - if (this.logger.isWarnEnabled()) { - this.logger.warn("Overriding user-defined bean definition for bean '" + beanName + + if (logger.isWarnEnabled()) { + logger.warn("Overriding user-defined bean definition for bean '" + beanName + "' with a framework-generated bean definition: replacing [" + oldBeanDefinition + "] with [" + beanDefinition + "]"); } } else if (!beanDefinition.equals(oldBeanDefinition)) { - if (this.logger.isInfoEnabled()) { - this.logger.info("Overriding bean definition for bean '" + beanName + + if (logger.isInfoEnabled()) { + logger.info("Overriding bean definition for bean '" + beanName + "' with a different definition: replacing [" + oldBeanDefinition + "] with [" + beanDefinition + "]"); } } else { - if (this.logger.isDebugEnabled()) { - this.logger.debug("Overriding bean definition for bean '" + beanName + + if (logger.isDebugEnabled()) { + logger.debug("Overriding bean definition for bean '" + beanName + "' with an equivalent definition: replacing [" + oldBeanDefinition + "] with [" + beanDefinition + "]"); } @@ -871,8 +871,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto BeanDefinition bd = this.beanDefinitionMap.remove(beanName); if (bd == null) { - if (this.logger.isTraceEnabled()) { - this.logger.trace("No bean named '" + beanName + "' found in " + this); + if (logger.isTraceEnabled()) { + logger.trace("No bean named '" + beanName + "' found in " + this); } throw new NoSuchBeanDefinitionException(beanName); } @@ -1656,7 +1656,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return createOptionalDependency(this.descriptor, this.beanName, args); } else { - DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) { + DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) { @Override public Object resolveCandidate(String beanName, Class requiredType, BeanFactory beanFactory) { return beanFactory.getBean(beanName, args); @@ -1677,7 +1677,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return createOptionalDependency(this.descriptor, this.beanName); } else { - DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) { + DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) { @Override public boolean isRequired() { return false; @@ -1690,7 +1690,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto @Override @Nullable public Object getIfUnique() throws BeansException { - DependencyDescriptor descriptorToUse = new DependencyDescriptor(descriptor) { + DependencyDescriptor descriptorToUse = new DependencyDescriptor(this.descriptor) { @Override public boolean isRequired() { return false; diff --git a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java index 36f5397bd46..94a757e1cfb 100644 --- a/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.java +++ b/spring-core/src/main/java/org/springframework/core/GenericTypeResolver.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. @@ -86,7 +86,7 @@ public abstract class GenericTypeResolver { */ @Nullable public static Class resolveReturnTypeArgument(Method method, Class genericIfc) { - Assert.notNull(method, "method must not be null"); + Assert.notNull(method, "Method must not be null"); ResolvableType resolvableType = ResolvableType.forMethodReturnType(method).as(genericIfc); if (!resolvableType.hasGenerics() || resolvableType.getType() instanceof WildcardType) { return null; diff --git a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java index 272a9c9cbee..c9dbf400573 100644 --- a/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.java +++ b/spring-core/src/main/java/org/springframework/core/SerializableTypeWrapper.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. @@ -31,7 +31,6 @@ import java.lang.reflect.TypeVariable; import java.lang.reflect.WildcardType; import org.springframework.lang.Nullable; -import org.springframework.util.Assert; import org.springframework.util.ConcurrentReferenceHashMap; import org.springframework.util.ObjectUtils; import org.springframework.util.ReflectionUtils; @@ -69,7 +68,6 @@ abstract class SerializableTypeWrapper { */ @Nullable public static Type forField(Field field) { - Assert.notNull(field, "Field must not be null"); return forTypeProvider(new FieldTypeProvider(field)); } @@ -135,21 +133,20 @@ abstract class SerializableTypeWrapper { * Return a {@link Serializable} {@link Type} backed by a {@link TypeProvider} . */ @Nullable - static Type forTypeProvider(final TypeProvider provider) { - Assert.notNull(provider, "Provider must not be null"); + static Type forTypeProvider(TypeProvider provider) { Type providedType = provider.getType(); - if (providedType == null) { - return null; - } - if (providedType instanceof Serializable) { + if (providedType == null || providedType instanceof Serializable) { + // No serializable type wrapping necessary (e.g. for java.lang.Class) return providedType; } + + // Obtain a serializable type proxy for the given provider... Type cached = cache.get(providedType); if (cached != null) { return cached; } for (Class type : SUPPORTED_SERIALIZABLE_TYPES) { - if (type.isAssignableFrom(providedType.getClass())) { + if (type.isInstance(providedType)) { ClassLoader classLoader = provider.getClass().getClassLoader(); Class[] interfaces = new Class[] {type, SerializableTypeProxy.class, Serializable.class}; InvocationHandler handler = new TypeProxyInvocationHandler(provider); diff --git a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java index c6d34e67c3d..2afa64d5345 100644 --- a/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java +++ b/spring-core/src/main/java/org/springframework/core/SimpleAliasRegistry.java @@ -69,7 +69,7 @@ public class SimpleAliasRegistry implements AliasRegistry { throw new IllegalStateException("Cannot define alias '" + alias + "' for name '" + name + "': It is already registered for name '" + registeredName + "'."); } - if (this.logger.isInfoEnabled()) { + if (logger.isInfoEnabled()) { logger.info("Overriding alias '" + alias + "' definition for registered name '" + registeredName + "' with new target name '" + name + "'"); } diff --git a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java index c33cbedfb41..c67c6f1518c 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpHeaders.java +++ b/spring-web/src/main/java/org/springframework/http/HttpHeaders.java @@ -172,7 +172,7 @@ public class HttpHeaders implements MultiValueMap, Serializable */ public static final String CONTENT_ENCODING = "Content-Encoding"; /** - * The HTTP {@code Content-Disposition} header field name + * The HTTP {@code Content-Disposition} header field name. * @see RFC 6266 */ public static final String CONTENT_DISPOSITION = "Content-Disposition"; @@ -378,7 +378,7 @@ public class HttpHeaders implements MultiValueMap, Serializable public static final String WWW_AUTHENTICATE = "WWW-Authenticate"; /** - * Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match" + * Pattern matching ETag multiple field values in headers such as "If-Match", "If-None-Match". * @see Section 2.3 of RFC 7232 */ private static final Pattern ETAG_HEADER_VALUE_PATTERN = Pattern.compile("\\*|\\s*((W\\/)?(\"[^\"]*\"))\\s*,?"); @@ -388,7 +388,7 @@ public class HttpHeaders implements MultiValueMap, Serializable private static final ZoneId GMT = ZoneId.of("GMT"); /** - * Date formats with time zone as specified in the HTTP RFC + * Date formats with time zone as specified in the HTTP RFC. * @see Section 7.1.1.1 of RFC 7231 */ private static final DateTimeFormatter[] DATE_FORMATTERS = new DateTimeFormatter[] { @@ -1281,7 +1281,7 @@ public class HttpHeaders implements MultiValueMap, Serializable * {@link IllegalArgumentException} ({@code true}) or rather return {@code null} * in that case ({@code false}) * @return the parsed date header, or {@code null} if none (or invalid) - */ + */ @Nullable private ZonedDateTime getFirstZonedDateTime(String headerName, boolean rejectInvalid) { String headerValue = getFirst(headerName);