Description
Marcin Piela opened SPR-12526 and commented
I created an interface (Service) with two implementations (FirstService, SecondService) with one dependency each (DependencyOne, DependencyTwo, respectively). The dependencies are to be injected via a @Resource
annotated setter method.
In a spring java configuration class I created a @Bean
method with @Scope
=prototype that based on some custom condition creates FirstService or SecondService using "new" operator. The method return type is Service.
The problem is that when the method first creates an instance of FirstService and then the custom condition changes and on the second run an instance of SecondService is created it (SecondService instance) does not get populated with dependencies.
I've attached a simple maven module with a test case to demonstrate the issue.
Affects: 3.2.12, 4.0.8, 4.1.2
Attachments:
- spring-bug.zip (5.05 kB)