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
Bug introduced with Spring Cloud Context version: 3.0.0
When the LegacyContextRefresher is used to refresh the Spring environment properties, the temporary context created by the LegacyContextRefresher, does no longer get the defaultProperties property source propagated from the original environment.
The reason for this is because the properties method of the SpringApplicationBuilder is now used to provide the spring.cloud.bootstrap.enabled=true property to the builder. This results in the defaultProperties property source from the copied environment to be overwritten by a new property map containing only the spring.cloud.bootstrap.enabled property.
To put this in sequence (with line references to the code):
The copyEnvironment is used to copy the defaultProperties and commandLineArgs property sources from the environment of the real context
A SpringApplicationBuilder is created and it gets that copied environment but also the spring.cloud.bootstrap.enabled=true property via the properties build method.
because the spring.cloud.bootstrap.enabled=true property is set on the SpringApplicationBuilderit will create a new DefaultPropertiesPropertySource and overwrite the one from the copied environment. Thus the original default properties are lost.
The solution would be to provide the spring.cloud.bootstrap.enabled=true via other means, for instance by adding it to the default properties of the copied environment, instead of using the properties method of the SpringApplicationBuilder.
The text was updated successfully, but these errors were encountered:
Also spend 3 hours to find this same case. I am not sure if this is a spring-cloud bug or also a spring-boot bug. Seems to me that DefaultPropertiesPropertySource might want to merge if another DefaultPropertiesPropertySource exists?
Could this be confirmed or am I doing something wrong, any workarounds? @philwebb
Bug introduced with Spring Cloud Context version: 3.0.0
When the
LegacyContextRefresher
is used to refresh the Spring environment properties, the temporary context created by the LegacyContextRefresher, does no longer get thedefaultProperties
property source propagated from the original environment.The reason for this is because the
properties
method of theSpringApplicationBuilder
is now used to provide thespring.cloud.bootstrap.enabled=true
property to the builder. This results in thedefaultProperties
property source from the copied environment to be overwritten by a new property map containing only thespring.cloud.bootstrap.enabled
property.To put this in sequence (with line references to the code):
LegacyContextRefresher#updateEnvironment
get called to update the environmentaddConfigFilesToEnvironment
methodcopyEnvironment
is used to copy thedefaultProperties
andcommandLineArgs
property sources from the environment of the real contextSpringApplicationBuilder
is created and it gets that copied environment but also thespring.cloud.bootstrap.enabled=true
property via theproperties
build method.builder.run()
is called to build the temporary context and in this method:SpringApplicationBuilder
has any propertiesspring.cloud.bootstrap.enabled=true
property is set on theSpringApplicationBuilder
it will create a newDefaultPropertiesPropertySource
and overwrite the one from the copied environment. Thus the original default properties are lost.The solution would be to provide the
spring.cloud.bootstrap.enabled=true
via other means, for instance by adding it to the default properties of the copied environment, instead of using theproperties
method of theSpringApplicationBuilder
.The text was updated successfully, but these errors were encountered: