Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self reference fallback in 4.3 is not meant to apply to collection elements [SPR-14965] #19532

Closed
spring-issuemaster opened this issue Nov 30, 2016 · 0 comments

Comments

@spring-issuemaster
Copy link
Collaborator

commented Nov 30, 2016

Juergen Hoeller opened SPR-14965 and commented

Introducing self reference injection in 4.3, the revision of the algorithm accidentally also choses a self reference as a fallback element for an empty collection injection point. Of course, self references were only meant to be used as a direct dependency declaration, not as a collection element. This is also what the documentation and the existing test cases suggest.

A collection of the same type can be used for aggregates, e.g. propagating an event to listeners, with the aggregate also implementing the listener interface itself. This still works fine if there are delegate listener beans in the context but unfortunately fails as of 4.3 when the collection is declared as optional and meant to remain uninjected if no delegates are found, since all of a sudden there is a single-element collection with a self reference to the aggregate... This is a regression that needs to be fixed as of 4.3.5; better late than never.


Affects: 4.3.4

Issue Links:

  • #18536 Optional autowire of Map<String, BeanType> accidentally falls back to unrelated Map<String, String>
  • #13096 Support @Autowired-like self injection
  • #16794 @Autowired does not work for target bean of type Collection
  • #19563 Behaviour of field injection for List dependencies that are produced and consumed by the same configuration class has changed in 4.3.5 snapshots

Referenced from: commits 7ac9f92, ac5933a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.