Merge branch '2.4.x'

Closes gh-25031
pull/25033/head
Phillip Webb 4 years ago
commit 5054765fc8

@ -223,7 +223,7 @@ class ConfigDataEnvironmentContributor implements Iterable<ConfigDataEnvironment
ConfigDataEnvironmentContributor withBoundProperties(Binder binder) {
UseLegacyConfigProcessingException.throwIfRequested(binder);
ConfigDataProperties properties = ConfigDataProperties.get(binder);
if (this.configDataOptions.contains(ConfigData.Option.IGNORE_IMPORTS)) {
if (properties != null && this.configDataOptions.contains(ConfigData.Option.IGNORE_IMPORTS)) {
properties = properties.withoutImports();
}
return new ConfigDataEnvironmentContributor(Kind.BOUND_IMPORT, this.location, this.resource,

@ -26,6 +26,7 @@ import java.util.stream.Stream;
import org.junit.jupiter.api.Test;
import org.springframework.boot.cloud.CloudPlatform;
import org.springframework.boot.context.config.ConfigData.Option;
import org.springframework.boot.context.config.ConfigDataEnvironmentContributor.ImportPhase;
import org.springframework.boot.context.config.ConfigDataEnvironmentContributor.Kind;
import org.springframework.boot.context.properties.bind.Binder;
@ -334,6 +335,17 @@ class ConfigDataEnvironmentContributorTests {
() -> createBoundContributor(null, new ConfigData(Collections.singleton(propertySource)), 0));
}
@Test // gh-25029
void withBoundPropertiesWhenIgnoringImportsAndNothingBound() {
TestResource resource = new TestResource("a");
ConfigData configData = new ConfigData(Collections.singleton(new MockPropertySource()), Option.IGNORE_IMPORTS);
ConfigDataEnvironmentContributor contributor = ConfigDataEnvironmentContributor.ofUnboundImport(TEST_LOCATION,
resource, false, configData, 0);
Binder binder = new Binder(contributor.getConfigurationPropertySource());
ConfigDataEnvironmentContributor bound = contributor.withBoundProperties(binder);
assertThat(bound).isNotNull();
}
private ConfigDataEnvironmentContributor createBoundContributor(String location) {
return createBoundContributor(new TestResource(location),
new ConfigData(Collections.singleton(new MockPropertySource())), 0);

Loading…
Cancel
Save