2424
2525import org .springframework .beans .SimpleTypeConverter ;
2626import org .springframework .beans .TypeConverter ;
27+ import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
2728import org .springframework .beans .factory .config .BeanDefinitionHolder ;
2829import org .springframework .beans .factory .config .DependencyDescriptor ;
2930import org .springframework .beans .factory .support .AutowireCandidateQualifier ;
5354 */
5455public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwareAutowireCandidateResolver {
5556
56- private final Set <Class <? extends Annotation >> qualifierTypes = new LinkedHashSet <Class <? extends Annotation >>();
57+ private final Set <Class <? extends Annotation >> qualifierTypes = new LinkedHashSet <Class <? extends Annotation >>(2 );
5758
5859 private Class <? extends Annotation > valueAnnotationType = Value .class ;
5960
@@ -67,8 +68,8 @@ public class QualifierAnnotationAutowireCandidateResolver extends GenericTypeAwa
6768 public QualifierAnnotationAutowireCandidateResolver () {
6869 this .qualifierTypes .add (Qualifier .class );
6970 try {
70- this .qualifierTypes .add ((Class <? extends Annotation >)
71- ClassUtils . forName ( "javax.inject.Qualifier" , QualifierAnnotationAutowireCandidateResolver .class .getClassLoader ()));
71+ this .qualifierTypes .add ((Class <? extends Annotation >) ClassUtils . forName ( "javax.inject.Qualifier" ,
72+ QualifierAnnotationAutowireCandidateResolver .class .getClassLoader ()));
7273 }
7374 catch (ClassNotFoundException ex ) {
7475 // JSR-330 API not available - simply skip.
@@ -233,9 +234,14 @@ protected boolean checkQualifier(
233234 if (targetAnnotation == null ) {
234235 // Look for matching annotation on the target class
235236 if (getBeanFactory () != null ) {
236- Class <?> beanType = getBeanFactory ().getType (bdHolder .getBeanName ());
237- if (beanType != null ) {
238- targetAnnotation = AnnotationUtils .getAnnotation (ClassUtils .getUserClass (beanType ), type );
237+ try {
238+ Class <?> beanType = getBeanFactory ().getType (bdHolder .getBeanName ());
239+ if (beanType != null ) {
240+ targetAnnotation = AnnotationUtils .getAnnotation (ClassUtils .getUserClass (beanType ), type );
241+ }
242+ }
243+ catch (NoSuchBeanDefinitionException ex ) {
244+ // Not the usual case - simply forget about the type check...
239245 }
240246 }
241247 if (targetAnnotation == null && bd .hasBeanClass ()) {
0 commit comments