The problem is that we do want bootstrap properties to override
default properties in most cases, but if they are decrypted those
values have to be added with the highest possible precedence.
Fixes gh-54
EnvironmentChangeEvent should come before the RefreshScopeRefreshedEvent
so that all the @ConfigurationProperties are fully bound when the refresh
happens.
The main driver for this was a config server use case, where the server
wants to configure its own properties in the remote repo. It was working
up to a point, but the beans in bootstrap context were not refreshed
after the Environment was built so you had to manually refresh them to
get them to point to (e.g.) config repos configured remotely.
Fixes https://github.com/spring-cloud/spring-cloud-config/issues/139
The incoming (existing) environment needs to be used to initalize the
context that is created to grab the new environment, but we shouldn't
re-use the existing environment, rather just copy the property sources
and profiles.
The incoming (existing) environment needs to be used to initalize the
context that is created to grab the new environment, but we shouldn't
re-use the existing environment, rather just copy the property sources
and profiles.
The effect of not doing this is not often noticeable, but you sometimes
get a race condition between a context and its parent closing in different
threads without it.
If true (and spring.cloud.config.allowOverride=true) then the bootstrap
property source is added *last*, so all other property sources can override
it (including local config files).
Fixes gh-26, fixes gh-27.