Otherwise multiple instances of a scoped target can be created
if several threads need one at the same time. This isn't always
going to be a problem, but it breaks the singleton semantics, and
might lead to surprising results and/or performance issues if bean
creation is expensive.
It's kind of a corner case, but not a very small corner: if a /refresh
leads to a change in a key that was overridden from its default value (e.g.
n a profile-specific config file) then the key is not identified as changed.
The change is still applied.
This commit fixes the key computation and adds a couple of tests.
Fixes gh-73
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.