Skip to content

Commit 92c2102

Browse files
committed
Polishing
1 parent ae6d778 commit 92c2102

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

spring-context/src/main/java/org/springframework/context/annotation/BeanAnnotationHelper.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 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.
@@ -36,13 +36,14 @@ public static boolean isBeanAnnotated(Method method) {
3636
public static String determineBeanNameFor(Method beanMethod) {
3737
// By default, the bean name is the name of the @Bean-annotated method
3838
String beanName = beanMethod.getName();
39-
4039
// Check to see if the user has explicitly set a custom bean name...
4140
Bean bean = AnnotatedElementUtils.findMergedAnnotation(beanMethod, Bean.class);
42-
if (bean != null && bean.name().length > 0) {
43-
beanName = bean.name()[0];
41+
if (bean != null) {
42+
String[] names = bean.name();
43+
if (names.length > 0) {
44+
beanName = names[0];
45+
}
4446
}
45-
4647
return beanName;
4748
}
4849

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -626,22 +626,20 @@ public static boolean hasAnnotation(AnnotatedElement element, Class<? extends An
626626
* attributes of the same name from higher levels, and
627627
* {@link AliasFor @AliasFor} semantics are fully supported, both
628628
* within a single annotation and within the annotation hierarchy.
629-
* <p>In contrast to {@link #getAllAnnotationAttributes}, the search
630-
* algorithm used by this method will stop searching the annotation
631-
* hierarchy once the first annotation of the specified
632-
* {@code annotationType} has been found. As a consequence, additional
633-
* annotations of the specified {@code annotationType} will be ignored.
629+
* <p>In contrast to {@link #getAllAnnotationAttributes}, the search algorithm
630+
* used by this method will stop searching the annotation hierarchy once the
631+
* first annotation of the specified {@code annotationType} has been found.
632+
* As a consequence, additional annotations of the specified
633+
* {@code annotationType} will be ignored.
634634
* <p>This method follows <em>find semantics</em> as described in the
635635
* {@linkplain AnnotatedElementUtils class-level javadoc}.
636636
* @param element the annotated element
637637
* @param annotationType the annotation type to find
638638
* @param classValuesAsString whether to convert Class references into
639639
* Strings or to preserve them as Class references
640-
* @param nestedAnnotationsAsMap whether to convert nested Annotation
641-
* instances into {@code AnnotationAttributes} maps or to preserve them
642-
* as Annotation instances
643-
* @return the merged {@code AnnotationAttributes}, or {@code null} if
644-
* not found
640+
* @param nestedAnnotationsAsMap whether to convert nested Annotation instances into
641+
* {@code AnnotationAttributes} maps or to preserve them as Annotation instances
642+
* @return the merged {@code AnnotationAttributes}, or {@code null} if not found
645643
* @since 4.2
646644
* @see #findMergedAnnotation(AnnotatedElement, Class)
647645
* @see #getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)

spring-core/src/main/java/org/springframework/core/type/classreading/AnnotationAttributesReadingVisitor.java

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@
2929
import org.springframework.util.ObjectUtils;
3030

3131
/**
32-
* ASM visitor which looks for the annotations defined on a class or method, including
33-
* tracking meta-annotations.
32+
* ASM visitor which looks for annotations defined on a class or method,
33+
* including meta-annotations.
3434
*
35-
* <p>As of Spring 3.1.1, this visitor is fully recursive, taking into account any nested
36-
* annotations or nested annotation arrays. These annotations are in turn read into
37-
* {@link AnnotationAttributes} map structures.
35+
* <p>This visitor is fully recursive, taking into account any nested
36+
* annotations or nested annotation arrays.
3837
*
3938
* @author Juergen Hoeller
4039
* @author Chris Beams
@@ -77,9 +76,7 @@ public void visitEnd() {
7776
Annotation[] metaAnnotations = AnnotationUtils.getAnnotations(annotationClass);
7877
if (!ObjectUtils.isEmpty(metaAnnotations)) {
7978
for (Annotation metaAnnotation : metaAnnotations) {
80-
if (!AnnotationUtils.isInJavaLangAnnotationPackage(metaAnnotation)) {
81-
recursivelyCollectMetaAnnotations(visited, metaAnnotation);
82-
}
79+
recursivelyCollectMetaAnnotations(visited, metaAnnotation);
8380
}
8481
}
8582
if (this.metaAnnotationMap != null) {
@@ -111,7 +108,7 @@ private void recursivelyCollectMetaAnnotations(Set<Annotation> visited, Annotati
111108
}
112109
catch (Throwable ex) {
113110
if (logger.isDebugEnabled()) {
114-
logger.debug("Failed to introspect meta-annotations on [" + annotation + "]: " + ex);
111+
logger.debug("Failed to introspect meta-annotations on " + annotation + ": " + ex);
115112
}
116113
}
117114
}

0 commit comments

Comments
 (0)