@Lazy collection of optional elements should not crash when no candidates are found [SPR-15858] #20413
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: enhancement
A general enhancement
Milestone
spring-projects-issues commentedAug 10, 2017
•
edited
Antonio Anzivino opened SPR-15858 and commented
Hi,
I have an optional dependency to listener beans in one of my beans. That means that I could have any number of listeners in my Application context.
I have tried to annotate my bean the following way:
IMO it is intuitive that Spring will
I don't know if this is a bug in 4.3.5 or is it just how Spring is designed, but the above code, when no Listener bean is defined, crashes instead of returning an empty list when I try to access the listeners object.
If I use eager initialization, Autowired's required=false injects an empty list. I expected similar behaviour for lazy lists.
This ticket is:
My container bean's afterPropertiesSet does
Instead of logging 0, the application crashes with the following stack trace
Before submitting a test case, I'd first like to be clarified what is the expected Spring's behaviour in such situation
I have reviewed Spring docs on Lazy. The javadoc does not cite the case of optional Collection-dependencies
https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/Lazy.html
Affects: 4.3.5
Issue Links:
@Bean
return nullReferenced from: commits ec1eafc, 80bf394
The text was updated successfully, but these errors were encountered: