Skip to content

Commit 9a30748

Browse files
committed
Avoid duplicate class introspection during findAnnotationOnBean
Closes gh-22318
1 parent 596992c commit 9a30748

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,10 @@ public <A extends Annotation> A findAnnotationOnBean(String beanName, Class<A> a
586586
if (bd instanceof AbstractBeanDefinition) {
587587
AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
588588
if (abd.hasBeanClass()) {
589-
ann = AnnotationUtils.findAnnotation(abd.getBeanClass(), annotationType);
589+
Class<?> beanClass = abd.getBeanClass();
590+
if (beanClass != beanType) {
591+
ann = AnnotationUtils.findAnnotation(beanClass, annotationType);
592+
}
590593
}
591594
}
592595
}

0 commit comments

Comments
 (0)