Behaviour of field injection for List dependencies that are produced and consumed by the same configuration class has changed in 4.3.5 snapshots [SPR-14996] #19563
Comments
Juergen Hoeller commented I'm pretty sure that's a side effect of #19532 where we were trying to prevent self references in collections, fixing a regression between 4.2 and 4.3. Seems we're preventing references back to the same configuration class even; I'll see how we can relax that. Generally speaking, there is a lifecycle problem there though - a kind of circular reference: the |
Andy Wilkinson commented I haven't tried the real-world problem (it's in Boot) with static, but moving it to a separate configuration class does fix it. We did that (and moved to constructor injection at the same time) in Boot 2.0 when I noticed the problem with the 5.0 snapshots. We could do the same here but, strictly speaking, it would be a breaking change as it's a public configuration class that's affected. That said, I don't like our current configuration arrangement. If this behaviour can't be fine-tuned we'll change Boot. |
Juergen Hoeller commented We're allowing factory references back to the same bean now, making your scenario work again (also for compatibility with 4.2's behavior). However, we're still not considering a direct self reference (i.e. the very same bean) as a candidate for a dependency collection (like 4.2 didn't either). |
Andy Wilkinson opened SPR-14996 and commented
I noticed this in 5.0 as well but didn't think too much of it, however I've just noticed that the latest 4.3.5 snapshots exhibit the same change in behaviour.
Here's small application that will reproduce the problem:
It will run successfully with 4.3.4.RELEASE and fail with 4.3.5.BUILD-SNAPSHOT due to
things
beingnull
.It also works without
required=false
with 4.3.4.RELEASE but fails with aNoSuchBeanDefinitionException
with 4.3.5.BUILD-SNAPSHOT.It works with both 4.3.4.RELEASE and 4.3.5.BUILD-SNAPSHOT if the field is
Thing
rather thanList<Thing>
.Affects: 4.3.5
Issue Links:
Referenced from: commits 547b963, 4571975
The text was updated successfully, but these errors were encountered: