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 4709420e35..ad4c9c07a5 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 @@ -769,8 +769,8 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp if (this.parentBeanFactory != null && this.parentBeanFactory != parentBeanFactory) { throw new IllegalStateException("Already associated with parent BeanFactory: " + this.parentBeanFactory); } - if(this == parentBeanFactory) { - throw new IllegalStateException("Can not set parent bean factory to self."); + if (this == parentBeanFactory) { + throw new IllegalStateException("Cannot set parent bean factory to self"); } this.parentBeanFactory = parentBeanFactory; } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java index 1704045400..bc309c7254 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/TypeMappedAnnotation.java @@ -73,18 +73,19 @@ final class TypeMappedAnnotation extends AbstractMergedAnn private static final Map, Object> EMPTY_ARRAYS; static { Map, Object> emptyArrays = new HashMap<>(); - emptyArrays.put(String.class, new String[] {}); - emptyArrays.put(boolean.class, new boolean[] {}); - emptyArrays.put(byte.class, new byte[] {}); - emptyArrays.put(char.class, new char[] {}); - emptyArrays.put(double.class, new double[] {}); - emptyArrays.put(float.class, new float[] {}); - emptyArrays.put(int.class, new int[] {}); - emptyArrays.put(long.class, new long[] {}); - emptyArrays.put(short.class, new short[] {}); + emptyArrays.put(boolean.class, new boolean[0]); + emptyArrays.put(byte.class, new byte[0]); + emptyArrays.put(char.class, new char[0]); + emptyArrays.put(double.class, new double[0]); + emptyArrays.put(float.class, new float[0]); + emptyArrays.put(int.class, new int[0]); + emptyArrays.put(long.class, new long[0]); + emptyArrays.put(short.class, new short[0]); + emptyArrays.put(String.class, new String[0]); EMPTY_ARRAYS = Collections.unmodifiableMap(emptyArrays); } + private final AnnotationTypeMapping mapping; @Nullable @@ -427,9 +428,8 @@ final class TypeMappedAnnotation extends AbstractMergedAnn } } if (!forMirrorResolution) { - attributeIndex = (mapping.getDistance() != 0 ? - this.resolvedMirrors : - this.resolvedRootMirrors)[attributeIndex]; + attributeIndex = + (mapping.getDistance() != 0 ? this.resolvedMirrors : this.resolvedRootMirrors)[attributeIndex]; } if (attributeIndex == -1) { return null; @@ -437,15 +437,13 @@ final class TypeMappedAnnotation extends AbstractMergedAnn if (mapping.getDistance() == 0) { Method attribute = mapping.getAttributes().get(attributeIndex); Object result = this.valueExtractor.extract(attribute, this.rootAttributes); - return (result != null) ? result : attribute.getDefaultValue(); + return (result != null ? result : attribute.getDefaultValue()); } return getValueFromMetaAnnotation(attributeIndex, forMirrorResolution); } @Nullable - private Object getValueFromMetaAnnotation(int attributeIndex, - boolean forMirrorResolution) { - + private Object getValueFromMetaAnnotation(int attributeIndex, boolean forMirrorResolution) { Object value = null; if (this.useMergedValues || forMirrorResolution) { value = this.mapping.getMappedAnnotationValue(attributeIndex, forMirrorResolution); @@ -479,7 +477,7 @@ final class TypeMappedAnnotation extends AbstractMergedAnn value = ClassUtils.resolveClassName((String) value, getClassLoader()); } else if (value instanceof Class[] && type == String[].class) { - Class[] classes = (Class[]) value; + Class[] classes = (Class[]) value; String[] names = new String[classes.length]; for (int i = 0; i < classes.length; i++) { names[i] = classes[i].getName(); @@ -522,10 +520,9 @@ final class TypeMappedAnnotation extends AbstractMergedAnn return adaptForAttribute(attribute, array); } if (attributeType.isAnnotation()) { - return adaptToMergedAnnotation(value,(Class) attributeType); + return adaptToMergedAnnotation(value, (Class) attributeType); } - if (attributeType.isArray() && attributeType.getComponentType().isAnnotation() && - value.getClass().isArray()) { + if (attributeType.isArray() && attributeType.getComponentType().isAnnotation()) { MergedAnnotation[] result = new MergedAnnotation[Array.getLength(value)]; for (int i = 0; i < result.length; i++) { result[i] = adaptToMergedAnnotation(Array.get(value, i), diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java index 60b07a4268..c5ce3a3683 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/method/annotation/ModelAttributeMethodArgumentResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2020 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. @@ -151,6 +151,7 @@ public class ModelAttributeMethodArgumentResolver extends HandlerMethodArgumentR * Extension point to bind the request to the target object. * @param binder the data binder instance to use for the binding * @param exchange the current request + * @since 5.2.6 */ protected Mono bindRequestParameters(WebExchangeDataBinder binder, ServerWebExchange exchange) { return binder.bind(exchange);