-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Plain FactoryBean declaration on @Bean method leads to early call (pre injection) [SPR-12141] #16755
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
Comments
Juergen Hoeller commented This turns out to happen during type matching for the "env" field, considering the local FactoryBean Juergen |
Juergen Hoeller commented This is available in the latest 4.1 and 4.0.7 snapshots now, and soon in a 3.2.11 snapshot as well. If you have the chance, please give it a try today; the public releases are scheduled for tomorrow European morning! Juergen |
Michał Jaśtak commented Checked with 4.1.0.BUILD-SNAPSHOT - nothing changed, I'll double check when 4.1 will be released, for now I'm just using workaround:
|
Juergen Hoeller commented That's strange... Could you please double-check that you've actually been using the latest snapshot? Sometimes older snapshots are locally cached... In any case, you should not be seeing such an early call to the Juergen |
Juergen Hoeller commented I've just double-checked on my side, with a specific test for HttpInvokerProxyFactoryBean analogous to yours, that the fix does solve the problem to the best of my understanding. Reverting the fix makes it break with an NPE again. So I do suspect a snapshot cache problem on your end - please retry, it'd be great to know the results on your end! Juergen |
Michał Jaśtak commented My build is using 4.1.0.BUILD-20140903.110329-464 version of SF, and indeed I'm still getting NPEx :( - When I changed the code to:
I had to add
Maybe that will give you a clue what's going on ... |
Juergen Hoeller commented Hmm, whatever variant I try based on those code snippets, I can't reproduce a remaining NPE against the latest 4.1 snapshot. I suspect that there's some other factor involved :-( Could you provide a minimal test case that does fail against the latest 4.1 snapshot for you? Juergen |
Michał Jaśtak commented I agree with you, there must be something more in my SF configuration, which impacts this situation, I'll try to prepare the test case for it, but that will be probably over the weekend :( - thus don't wait with releasing 4.1 for me ;) - we will return to it in next days. M. |
Michał Jaśtak opened SPR-12141 and commented
Suppose that I have class annotated with
@Configuration
, in which I want to use Environment, injected by Spring Framework, something like this:When I declare bean using HttpInvokerProxyFactoryBean, and try to access injected environment to use one or the properties as for ex. service URL
I get NPEx because Spring Framework is trying to instantiate the factory before Environment is injected.
The problem doesn't exist, if I declare returned type as FactoryBean<SomeService>, but because of current signature of HttpInvokerProxyFactoryBean, I'm unable to use it directly (it implements FactoryBean<Object>).
Affects: 3.2.10, 4.0.6, 4.1 RC2
Issue Links:
@Bean
Referenced from: commits 4432c41, f4f7f40, 5da8a16, bff2bf2
Backported to: 4.0.7, 3.2.11
The text was updated successfully, but these errors were encountered: