Closed
Description
Stefan Mueller opened SPR-16342 and commented
#20582 and #20711 fixed a similar bug. The problem still exists if calling ctx.getBean(name, type) for a null-bean which in older Spring versions (pre 5) returned null and now throws a org.springframework.beans.factory.BeanNotOfRequiredTypeException.
Can be reproduced by adding the following to spring-framework-issues
assertNotNull(ctx.getBean("bean1", IDummy.class)); // Works
assertNull(ctx.getBean("bean4", IDummy.class)); // Throws a BeanNotOfRequiredTypeException
Affects: 5.0.2
Issue Links:
- CastClass exception when wiring Map of beans (NullBean instead of 'null' in the map) [SPR-16033] #20582 CastClass exception when wiring Map of beans (NullBean instead of 'null' in the map)
- CastClass exception (NullBean instead of 'null' value) when getting map of beans directly from ApplicationContext [SPR-16163] #20711 CastClass exception (NullBean instead of 'null' value) when getting map of beans directly from ApplicationContext
- Introduce null-safety of Spring Framework API [SPR-15540] #20099 Introduce null-safety of Spring Framework API
- Autowire contract is not honored in cases where FactoryBean or @Bean return null [SPR-15829] #20384 Autowire contract is not honored in cases where FactoryBean or
@Bean
return null - DefaultLifecycleProcessor throws BeanNotOfRequiredType for null beans (cause of NullBean instance cannot be converted) [SPR-16343] #20890 DefaultLifecycleProcessor throws BeanNotOfRequiredType for null beans (cause of NullBean instance cannot be converted)