diff --git a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java b/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java index 3befe100726..03a03c1f01f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.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. @@ -19,6 +19,7 @@ package org.springframework.beans.annotation; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -58,8 +59,11 @@ public abstract class AnnotationBeanUtils { * @param excludedProperties the names of excluded properties, if any * @see org.springframework.beans.BeanWrapper */ - public static void copyPropertiesToBean(Annotation ann, Object bean, StringValueResolver valueResolver, String... excludedProperties) { - Set excluded = new HashSet(Arrays.asList(excludedProperties)); + public static void copyPropertiesToBean(Annotation ann, Object bean, StringValueResolver valueResolver, + String... excludedProperties) { + + Set excluded = (excludedProperties.length == 0 ? Collections.emptySet() : + new HashSet(Arrays.asList(excludedProperties))); Method[] annotationProperties = ann.annotationType().getDeclaredMethods(); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(bean); for (Method annotationProperty : annotationProperties) { diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java index 4d9d0dabf36..31da00686f2 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java @@ -278,7 +278,7 @@ abstract class AutowireUtils { /** - * Reflective InvocationHandler for lazy access to the current target object. + * Reflective {@link InvocationHandler} for lazy access to the current target object. */ @SuppressWarnings("serial") private static class ObjectFactoryDelegatingInvocationHandler implements InvocationHandler, Serializable { diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java index 1dc7338142b..48cf786160a 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.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. @@ -27,6 +27,8 @@ import org.springframework.util.ReflectionUtils; import static org.junit.Assert.*; /** + * Unit tests for {@link AutowireUtils}. + * * @author Juergen Hoeller * @author Sam Brannen */ @@ -36,7 +38,7 @@ public class AutowireUtilsTests { public void genericMethodReturnTypes() { Method notParameterized = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterized"); assertEquals(String.class, - AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterized, new Object[]{}, getClass().getClassLoader())); + AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterized, new Object[0], getClass().getClassLoader())); Method notParameterizedWithArguments = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterizedWithArguments", Integer.class, Boolean.class); assertEquals(String.class, diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index de9dfd9fb2c..fccfc00effe 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.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. @@ -51,14 +51,14 @@ import org.springframework.util.StringUtils; *

Note that most of the features of this class are not provided by the * JDK's introspection facilities themselves. * - *

As a general rule for runtime-retained annotations (e.g. for transaction - * control, authorization, or service exposure), always use the lookup methods - * on this class (e.g., {@link #findAnnotation(Method, Class)}, - * {@link #getAnnotation(Method, Class)}, and {@link #getAnnotations(Method)}) - * instead of the plain annotation lookup methods in the JDK. You can still - * explicitly choose between a get lookup on the given class level only - * ({@link #getAnnotation(Method, Class)}) and a find lookup in the entire - * inheritance hierarchy of the given method ({@link #findAnnotation(Method, Class)}). + *

As a general rule for runtime-retained application annotations (e.g. for + * transaction control, authorization, or service exposure), always use the + * lookup methods on this class (e.g. {@link #findAnnotation(Method, Class)} or + * {@link #getAnnotation(Method, Class)}) instead of the plain annotation lookup + * methods in the JDK. You can still explicitly choose between a get + * lookup on the given class level only ({@link #getAnnotation(Method, Class)}) + * and a find lookup in the entire inheritance hierarchy of the given + * method ({@link #findAnnotation(Method, Class)}). * *

Terminology

* The terms directly present, indirectly present, and @@ -542,7 +542,7 @@ public abstract class AnnotationUtils { /** * Find a single {@link Annotation} of {@code annotationType} on the supplied - * {@link Method}, traversing its super methods (i.e., from superclasses and + * {@link Method}, traversing its super methods (i.e. from superclasses and * interfaces) if the annotation is not directly present on the given * method itself. *

Correctly handles bridge {@link Method Methods} generated by the compiler. diff --git a/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityDecoder.java b/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityDecoder.java index 465c3e5f4bb..2277edfff3a 100644 --- a/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityDecoder.java +++ b/spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityDecoder.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. @@ -66,8 +66,9 @@ class HtmlCharacterEntityDecoder { this.originalMessage.indexOf('&', this.nextPotentialReferencePosition); if (this.nextSemicolonPosition != -1 && - this.nextSemicolonPosition < this.nextPotentialReferencePosition) + this.nextSemicolonPosition < this.nextPotentialReferencePosition) { this.nextSemicolonPosition = this.originalMessage.indexOf(';', this.nextPotentialReferencePosition + 1); + } boolean isPotentialReference = (this.nextPotentialReferencePosition != -1 && this.nextSemicolonPosition != -1 && @@ -94,12 +95,13 @@ class HtmlCharacterEntityDecoder { int skipUntilIndex = (this.nextPotentialReferencePosition != -1 ? this.nextPotentialReferencePosition : this.originalMessage.length()); if (skipUntilIndex - this.currentPosition > 3) { - this.decodedMessage.append(this.originalMessage.substring(this.currentPosition, skipUntilIndex)); + this.decodedMessage.append(this.originalMessage, this.currentPosition, skipUntilIndex); this.currentPosition = skipUntilIndex; } else { - while (this.currentPosition < skipUntilIndex) + while (this.currentPosition < skipUntilIndex) { this.decodedMessage.append(this.originalMessage.charAt(this.currentPosition++)); + } } } } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java index d4303fb8811..baf17afa159 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.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. @@ -442,7 +442,7 @@ public abstract class ResponseEntityExceptionHandler { } /** - * Customize the response for NoHandlerFoundException. + * Customize the response for AsyncRequestTimeoutException. *

This method delegates to {@link #handleExceptionInternal}. * @param ex the exception * @param headers the headers to be written to the response @@ -470,7 +470,7 @@ public abstract class ResponseEntityExceptionHandler { } /** - * A single place to customize the response body of all Exception types. + * A single place to customize the response body of all exception types. *

The default implementation sets the {@link WebUtils#ERROR_EXCEPTION_ATTRIBUTE} * request attribute and creates a {@link ResponseEntity} from the given * body, headers, and status.