Merge branch '2.7.x'

pull/29429/head
Phillip Webb 3 years ago
commit 3146465d25

@ -87,15 +87,17 @@ public final class ConfigurationPropertySources {
Assert.isInstanceOf(ConfigurableEnvironment.class, environment); Assert.isInstanceOf(ConfigurableEnvironment.class, environment);
MutablePropertySources sources = ((ConfigurableEnvironment) environment).getPropertySources(); MutablePropertySources sources = ((ConfigurableEnvironment) environment).getPropertySources();
PropertySource<?> attached = getAttached(sources); PropertySource<?> attached = getAttached(sources);
if (attached != null) { if (attached == null || !isUsingSources(attached, sources)) {
if (attached instanceof ConfigurationPropertySourcesPropertySource attached = new ConfigurationPropertySourcesPropertySource(ATTACHED_PROPERTY_SOURCE_NAME,
&& ((SpringConfigurationPropertySources) attached.getSource()).isUsingSources(sources)) { new SpringConfigurationPropertySources(sources));
return;
}
sources.remove(ATTACHED_PROPERTY_SOURCE_NAME);
} }
sources.addFirst(new ConfigurationPropertySourcesPropertySource(ATTACHED_PROPERTY_SOURCE_NAME, sources.remove(ATTACHED_PROPERTY_SOURCE_NAME);
new SpringConfigurationPropertySources(sources))); sources.addFirst(attached);
}
private static boolean isUsingSources(PropertySource<?> attached, MutablePropertySources sources) {
return attached instanceof ConfigurationPropertySourcesPropertySource
&& ((SpringConfigurationPropertySources) attached.getSource()).isUsingSources(sources);
} }
static PropertySource<?> getAttached(MutablePropertySources sources) { static PropertySource<?> getAttached(MutablePropertySources sources) {

Loading…
Cancel
Save