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

FactoryBean initialization with unresolved properties #439

Closed
stahloss opened this issue Oct 31, 2018 · 4 comments
Closed

FactoryBean initialization with unresolved properties #439

stahloss opened this issue Oct 31, 2018 · 4 comments

Comments

@stahloss
Copy link

stahloss commented Oct 31, 2018

Hi spring-cloud-commons,

I encountered a bug with using FactoryBean combined with the Spring Cloud Config Server. The guys from spring-cloud-config were nice enough to fix the issue in spring-cloud-commons.

They fixed a initialization cascade, but the log from the demo project shows that the properties are loaded and should be resolvable when the FactoryBean is initialized.
I also find that with the fixed spring-cloud-context, the problem is still present when deploying on PCF.

So I'm creating this issue in the hopes you could implement an improvement that makes sure the properties are resolved and available to FactoryBeans upon initialization.

@ryanjbaxter
Copy link
Contributor

Here was the fix 9b8a70e

@ryanjbaxter
Copy link
Contributor

Something else to consider. This worked in Edgware.SR5. The code in RefreshAutoConfiguration changed between Edgware and Finchley, so it seems likely that that code change is what caused the problem in Finchley. My question is whether the logging in Edgware indicates the same thing? If so then this functionality has most likely been the same for a long time then.

@stahloss
Copy link
Author

The logging is the same. Yes I think it's been like this for a long time. It's probably a fundamental issue in the way or order things are executed.

I would say you first load the properties and then instantiate any FactoryBeans that require properties, or not even load any FactoryBeans before loading the properties. The latter is probably not possible, because FactoryBeans are involved in loading properties.

Another thing to consider (in the unfixed situation): My class implements InitializingBean. When the afterPropertiesSet method is called, the ${ssl.keystore.file} property is resolved, but the other two are not. They all come from the same PropertySource. This is very strange to me as well. Seems that some mechanism is preventing the other two properties to resolve, while they clearly should be.

@stahloss
Copy link
Author

stahloss commented Dec 21, 2018

Did some more testing and with spring-cloud-dependencies:Greenwich.M3 the issue is resolved. Not sure why it seemed not to be before...

Using io.pivotal.spring.cloud:spring-cloud-services-config-client:2.0.3.RELEASE in my production project also shows that the issue is resolved. It's strange though, that using this in combination with spring-cloud-dependencies:Finchley.SR2 resolves the issue on PCF, but not in the demo project. There Greenwich.M3 is required.

Anyway, closing the issue. Thanks for your support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants