-
Notifications
You must be signed in to change notification settings - Fork 706
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
BootstrapApplicationListener overrides custom environment #596
Comments
I'm a bit unsure how we would go about doing that. It's too early in the lifecycle to have a bean. The only other thought would be to extract env creation to a protected method and then you'd need to setup your own entry in |
I can't think of a reason you'd want to override the environment implementation. Maybe we need to dig into the reason for asking in the first place, in case there's a better solution. |
Alright, we'll wait for the OP |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
This is the reason why we have a overridden environment implementation Consider following property Where MockCredentialVault is a type of Credential Vault System we want to access with the "Test" value So we need to have access to all property sources since the MockCredentialVault("Test") could also be in a different file application.properties prod.properties We felt that the a custom environment would be a better place to do this resolution as it has access to all property sources and in the case of custom environment we also have a central location to cache & refresh the retrieved credentials. |
That is very unusual and so far no one else has requested it. Let's see if there is more interest. |
I'm also still a bit unclear about why this can't be achieved with an |
The BootstrapApplicationListener defines its own environment when it creates the Spring Application using the Spring Builder. This overrides the custom environment we have provided for our application during the initial application run invocation.
We specify a custom environment class for our application for reasons specified in this issue
The BootstrapApplicationListener should provide a way for applications to specify their own environment class instead of defining its bootstrapEnvironment using new StandardEnvironment().
private ConfigurableApplicationContext bootstrapServiceContext( ConfigurableEnvironment environment, final SpringApplication application, String configName) { **StandardEnvironment bootstrapEnvironment = new StandardEnvironment();** MutablePropertySources bootstrapProperties = bootstrapEnvironment .getPropertySources(); for (PropertySource<?> source : bootstrapProperties) { bootstrapProperties.remove(source.getName()); }
The text was updated successfully, but these errors were encountered: