Skip to content

Commit c192c14

Browse files
committed
Polishing
1 parent d397d74 commit c192c14

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

spring-beans/src/main/java/org/springframework/beans/annotation/AnnotationBeanUtils.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,6 +19,7 @@
1919
import java.lang.annotation.Annotation;
2020
import java.lang.reflect.Method;
2121
import java.util.Arrays;
22+
import java.util.Collections;
2223
import java.util.HashSet;
2324
import java.util.Set;
2425

@@ -58,8 +59,11 @@ public static void copyPropertiesToBean(Annotation ann, Object bean, String... e
5859
* @param excludedProperties the names of excluded properties, if any
5960
* @see org.springframework.beans.BeanWrapper
6061
*/
61-
public static void copyPropertiesToBean(Annotation ann, Object bean, StringValueResolver valueResolver, String... excludedProperties) {
62-
Set<String> excluded = new HashSet<String>(Arrays.asList(excludedProperties));
62+
public static void copyPropertiesToBean(Annotation ann, Object bean, StringValueResolver valueResolver,
63+
String... excludedProperties) {
64+
65+
Set<String> excluded = (excludedProperties.length == 0 ? Collections.<String>emptySet() :
66+
new HashSet<String>(Arrays.asList(excludedProperties)));
6367
Method[] annotationProperties = ann.annotationType().getDeclaredMethods();
6468
BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(bean);
6569
for (Method annotationProperty : annotationProperties) {

spring-beans/src/main/java/org/springframework/beans/factory/support/AutowireUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ else if (arg instanceof TypedStringValue) {
278278

279279

280280
/**
281-
* Reflective InvocationHandler for lazy access to the current target object.
281+
* Reflective {@link InvocationHandler} for lazy access to the current target object.
282282
*/
283283
@SuppressWarnings("serial")
284284
private static class ObjectFactoryDelegatingInvocationHandler implements InvocationHandler, Serializable {

spring-beans/src/test/java/org/springframework/beans/factory/support/AutowireUtilsTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -27,6 +27,8 @@
2727
import static org.junit.Assert.*;
2828

2929
/**
30+
* Unit tests for {@link AutowireUtils}.
31+
*
3032
* @author Juergen Hoeller
3133
* @author Sam Brannen
3234
*/
@@ -36,7 +38,7 @@ public class AutowireUtilsTests {
3638
public void genericMethodReturnTypes() {
3739
Method notParameterized = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterized");
3840
assertEquals(String.class,
39-
AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterized, new Object[]{}, getClass().getClassLoader()));
41+
AutowireUtils.resolveReturnTypeForFactoryMethod(notParameterized, new Object[0], getClass().getClassLoader()));
4042

4143
Method notParameterizedWithArguments = ReflectionUtils.findMethod(MyTypeWithMethods.class, "notParameterizedWithArguments", Integer.class, Boolean.class);
4244
assertEquals(String.class,

spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -51,14 +51,14 @@
5151
* <p>Note that most of the features of this class are not provided by the
5252
* JDK's introspection facilities themselves.
5353
*
54-
* <p>As a general rule for runtime-retained annotations (e.g. for transaction
55-
* control, authorization, or service exposure), always use the lookup methods
56-
* on this class (e.g., {@link #findAnnotation(Method, Class)},
57-
* {@link #getAnnotation(Method, Class)}, and {@link #getAnnotations(Method)})
58-
* instead of the plain annotation lookup methods in the JDK. You can still
59-
* explicitly choose between a <em>get</em> lookup on the given class level only
60-
* ({@link #getAnnotation(Method, Class)}) and a <em>find</em> lookup in the entire
61-
* inheritance hierarchy of the given method ({@link #findAnnotation(Method, Class)}).
54+
* <p>As a general rule for runtime-retained application annotations (e.g. for
55+
* transaction control, authorization, or service exposure), always use the
56+
* lookup methods on this class (e.g. {@link #findAnnotation(Method, Class)} or
57+
* {@link #getAnnotation(Method, Class)}) instead of the plain annotation lookup
58+
* methods in the JDK. You can still explicitly choose between a <em>get</em>
59+
* lookup on the given class level only ({@link #getAnnotation(Method, Class)})
60+
* and a <em>find</em> lookup in the entire inheritance hierarchy of the given
61+
* method ({@link #findAnnotation(Method, Class)}).
6262
*
6363
* <h3>Terminology</h3>
6464
* The terms <em>directly present</em>, <em>indirectly present</em>, and
@@ -542,7 +542,7 @@ private static <A extends Annotation> A findAnnotation(
542542

543543
/**
544544
* Find a single {@link Annotation} of {@code annotationType} on the supplied
545-
* {@link Method}, traversing its super methods (i.e., from superclasses and
545+
* {@link Method}, traversing its super methods (i.e. from superclasses and
546546
* interfaces) if the annotation is not <em>directly present</em> on the given
547547
* method itself.
548548
* <p>Correctly handles bridge {@link Method Methods} generated by the compiler.

spring-web/src/main/java/org/springframework/web/util/HtmlCharacterEntityDecoder.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,8 +66,9 @@ private void findNextPotentialReference(int startPosition) {
6666
this.originalMessage.indexOf('&', this.nextPotentialReferencePosition);
6767

6868
if (this.nextSemicolonPosition != -1 &&
69-
this.nextSemicolonPosition < this.nextPotentialReferencePosition)
69+
this.nextSemicolonPosition < this.nextPotentialReferencePosition) {
7070
this.nextSemicolonPosition = this.originalMessage.indexOf(';', this.nextPotentialReferencePosition + 1);
71+
}
7172

7273
boolean isPotentialReference = (this.nextPotentialReferencePosition != -1 &&
7374
this.nextSemicolonPosition != -1 &&
@@ -94,12 +95,13 @@ private void copyCharactersTillPotentialReference() {
9495
int skipUntilIndex = (this.nextPotentialReferencePosition != -1 ?
9596
this.nextPotentialReferencePosition : this.originalMessage.length());
9697
if (skipUntilIndex - this.currentPosition > 3) {
97-
this.decodedMessage.append(this.originalMessage.substring(this.currentPosition, skipUntilIndex));
98+
this.decodedMessage.append(this.originalMessage, this.currentPosition, skipUntilIndex);
9899
this.currentPosition = skipUntilIndex;
99100
}
100101
else {
101-
while (this.currentPosition < skipUntilIndex)
102+
while (this.currentPosition < skipUntilIndex) {
102103
this.decodedMessage.append(this.originalMessage.charAt(this.currentPosition++));
104+
}
103105
}
104106
}
105107
}

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseEntityExceptionHandler.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -442,7 +442,7 @@ protected ResponseEntity<Object> handleNoHandlerFoundException(
442442
}
443443

444444
/**
445-
* Customize the response for NoHandlerFoundException.
445+
* Customize the response for AsyncRequestTimeoutException.
446446
* <p>This method delegates to {@link #handleExceptionInternal}.
447447
* @param ex the exception
448448
* @param headers the headers to be written to the response
@@ -470,7 +470,7 @@ protected ResponseEntity<Object> handleAsyncRequestTimeoutException(
470470
}
471471

472472
/**
473-
* A single place to customize the response body of all Exception types.
473+
* A single place to customize the response body of all exception types.
474474
* <p>The default implementation sets the {@link WebUtils#ERROR_EXCEPTION_ATTRIBUTE}
475475
* request attribute and creates a {@link ResponseEntity} from the given
476476
* body, headers, and status.

0 commit comments

Comments
 (0)