You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And given that ConsulPropertySourceLocator is a singleton in the bootstrap context, when the empty parent context (parentBuilder) is loaded it's Environment contains the following ConsulPropertySource's:
The problem is that the ConsulPropertySourceLocator is caching Consul context's from the previous ApplicationContext and just appending them together. And properties from the "B" profile that override properties from the "default" profile are not being picked up.
The current workaround I have, which is very much a hack is a @BoostrapConfiguration class that registers a BeanPostProcessor to wrap the ConsulPropertySourceLocator and clear() the context's before the next invocation of locate() is called.
Describe the bug
Spring Cloud Consul: 3.0.4
Spring Boot: 2.5.14
Java: 11
Given the following application context hierarchy:
And given that
ConsulPropertySourceLocator
is a singleton in thebootstrap
context, when the empty parent context (parentBuilder
) is loaded it'sEnvironment
contains the followingConsulPropertySource
's:This is all good and normal, but when the second context is loaded, it's
Environment
contains the followingConsulPropertySource
's:The problem is that the
ConsulPropertySourceLocator
is caching Consul context's from the previousApplicationContext
and just appending them together. And properties from the "B" profile that override properties from the "default" profile are not being picked up.The current workaround I have, which is very much a hack is a
@BoostrapConfiguration
class that registers aBeanPostProcessor
to wrap theConsulPropertySourceLocator
andclear()
the context's before the next invocation oflocate()
is called.It would be nice if this was fixed upstream and in a better manor than I have attempted here.
This then makes the
ConsulPropertySource
's for thatEnvironment
appear as expected:The text was updated successfully, but these errors were encountered: