Skip to content

Commit 5b06150

Browse files
committed
Deprecate correct method in AnnotatedElementUtils
1 parent 2a2a8d3 commit 5b06150

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ public static AnnotationAttributes getMergedAnnotationAttributes(AnnotatedElemen
402402
*/
403403
public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement element, Class<A> annotationType) {
404404
Assert.notNull(annotationType, "annotationType must not be null");
405-
return findMergedAnnotation(element, annotationType.getName());
405+
AnnotationAttributes attributes = findMergedAnnotationAttributes(element, annotationType, false, false);
406+
return (attributes != null ?
407+
AnnotationUtils.synthesizeAnnotation(attributes, annotationType, element) : null);
406408
}
407409

408410
/**
@@ -423,7 +425,9 @@ public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement ele
423425
* @see #findMergedAnnotation(AnnotatedElement, Class)
424426
* @see #findMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
425427
* @see AnnotationUtils#synthesizeAnnotation(Map, Class, AnnotatedElement)
428+
* @deprecated As of Spring Framework 4.2.3, use {@link #findMergedAnnotation(AnnotatedElement, Class)} instead.
426429
*/
430+
@Deprecated
427431
@SuppressWarnings("unchecked")
428432
public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement element, String annotationName) {
429433
AnnotationAttributes attributes = findMergedAnnotationAttributes(element, annotationName, false, false);
@@ -459,13 +463,11 @@ public static <A extends Annotation> A findMergedAnnotation(AnnotatedElement ele
459463
* @since 4.2
460464
* @see #findMergedAnnotation(AnnotatedElement, Class)
461465
* @see #getMergedAnnotationAttributes(AnnotatedElement, String, boolean, boolean)
462-
* @deprecated as of 4.2.3; use {@link #findMergedAnnotation(AnnotatedElement, Class)} instead
463466
*/
464-
@Deprecated
465467
public static AnnotationAttributes findMergedAnnotationAttributes(AnnotatedElement element,
466468
Class<? extends Annotation> annotationType, boolean classValuesAsString, boolean nestedAnnotationsAsMap) {
467469

468-
AnnotationAttributes attributes = searchWithFindSemantics(element, annotationType, null,
470+
AnnotationAttributes attributes = searchWithFindSemantics(element, annotationType, annotationType.getName(),
469471
new MergedAnnotationAttributesProcessor(annotationType, null, classValuesAsString, nestedAnnotationsAsMap));
470472
AnnotationUtils.postProcessAnnotationAttributes(element, attributes, classValuesAsString, nestedAnnotationsAsMap);
471473
return attributes;

0 commit comments

Comments
 (0)