Properly resolve null beans as getBeansOfType result entries
Issue: SPR-16163
This commit is contained in:
@@ -505,6 +505,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Map<String, T> getBeansOfType(@Nullable Class<T> type, boolean includeNonSingletons, boolean allowEagerInit)
|
||||
throws BeansException {
|
||||
|
||||
@@ -512,7 +513,8 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
|
||||
Map<String, T> result = new LinkedHashMap<>(beanNames.length);
|
||||
for (String beanName : beanNames) {
|
||||
try {
|
||||
result.put(beanName, getBean(beanName, type));
|
||||
Object beanInstance = getBean(beanName);
|
||||
result.put(beanName, (beanInstance instanceof NullBean ? null : (T) beanInstance));
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
Throwable rootCause = ex.getMostSpecificCause();
|
||||
|
||||
Reference in New Issue
Block a user