@@ -605,29 +605,32 @@ public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includ
605
605
606
606
@ Override
607
607
public String [] getBeanNamesForAnnotation (Class <? extends Annotation > annotationType ) {
608
- List <String > results = new ArrayList <>();
608
+ List <String > result = new ArrayList <>();
609
609
for (String beanName : this .beanDefinitionNames ) {
610
610
BeanDefinition beanDefinition = getBeanDefinition (beanName );
611
611
if (!beanDefinition .isAbstract () && findAnnotationOnBean (beanName , annotationType ) != null ) {
612
- results .add (beanName );
612
+ result .add (beanName );
613
613
}
614
614
}
615
615
for (String beanName : this .manualSingletonNames ) {
616
- if (!results .contains (beanName ) && findAnnotationOnBean (beanName , annotationType ) != null ) {
617
- results .add (beanName );
616
+ if (!result .contains (beanName ) && findAnnotationOnBean (beanName , annotationType ) != null ) {
617
+ result .add (beanName );
618
618
}
619
619
}
620
- return StringUtils .toStringArray (results );
620
+ return StringUtils .toStringArray (result );
621
621
}
622
622
623
623
@ Override
624
624
public Map <String , Object > getBeansWithAnnotation (Class <? extends Annotation > annotationType ) {
625
625
String [] beanNames = getBeanNamesForAnnotation (annotationType );
626
- Map <String , Object > results = new LinkedHashMap <>(beanNames .length );
626
+ Map <String , Object > result = new LinkedHashMap <>(beanNames .length );
627
627
for (String beanName : beanNames ) {
628
- results .put (beanName , getBean (beanName ));
628
+ Object beanInstance = getBean (beanName );
629
+ if (!(beanInstance instanceof NullBean )) {
630
+ result .put (beanName , beanInstance );
631
+ }
629
632
}
630
- return results ;
633
+ return result ;
631
634
}
632
635
633
636
/**
0 commit comments