Merge branch '2.4.x'

Closes gh-26679
pull/26690/head
Phillip Webb 4 years ago
commit 91eb37dd84

@ -268,7 +268,7 @@ public class StandardConfigDataLocationResolver
private Set<StandardConfigDataResource> resolvePatternEmptyDirectories(StandardConfigDataReference reference) {
Resource[] subdirectories = this.resourceLoader.getResources(reference.getDirectory(), ResourceType.DIRECTORY);
ConfigDataLocation location = reference.getConfigDataLocation();
if (location.isOptional() && ObjectUtils.isEmpty(subdirectories)) {
if (!location.isOptional() && ObjectUtils.isEmpty(subdirectories)) {
String message = String.format("Config data location '%s' contains no subdirectories", location);
throw new ConfigDataLocationNotFoundException(location, message, null);
}

@ -715,7 +715,14 @@ class ConfigDataEnvironmentPostProcessorIntegrationTests {
void runWhenMandatoryWildcardLocationHasNoSubdirectories() {
assertThatExceptionOfType(ConfigDataLocationNotFoundException.class).isThrownBy(
() -> this.application.run("--spring.config.location=file:src/test/resources/config/0-empty/*/"))
.withMessage("Config data location 'file:src/test/resources/config/0-empty/*/' cannot be found");
.withMessage(
"Config data location 'file:src/test/resources/config/0-empty/*/' contains no subdirectories");
}
@Test
void runWhenOptionalWildcardLocationHasNoSubdirectories() {
assertThatNoException().isThrownBy(() -> this.application
.run("--spring.config.location=optional:file:src/test/resources/config/0-empty/*/"));
}
@Test

Loading…
Cancel
Save