Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Doc: @Autowired properties not reliably set in FactoryBean before getObject [SPR-8704] #13346
If I have a factoryBean with an
I wasn't able to find a similar issue, bu #12108 may be related. It's possible I don't understand the guarantees provided by a FactoryBean. See the test case attached to this issue, and I'll see about adding it to the github test cases.
If two bean factories are declared with:
And the DependentBeanFactory has:
dependentBean.getObject() can be called before myFancyBean is set, often leading to a NullPointerException or other issue.
2 votes, 8 watchers
Juergen Hoeller commented
Spencer Gibb, we tend to generally recommend against using annotation-driven injection in
That said, we can certainly try to provide stronger guarantees here... maybe 5.0 only though, depending on the effort and lifecycle impact.