Skip to content

The error message when a wildcard directory location does not match any files is misleading #26415

@ryanjbaxter

Description

@ryanjbaxter

In my app's application.yaml I have

spring:
  config:
    import: file:/Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files/*/

The directory /Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files looks like this

~ ls -l /Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files
total 48
-rw-r--r--  1 ryanjbaxter  staff  646 May  6 21:03 application.yml
-rw-r--r--  1 ryanjbaxter  staff  483 May  6 21:02 blueorgreen.yml
-rw-r--r--  1 ryanjbaxter  staff   17 Apr 21 11:16 blueorgreenauthgateway.yml
-rw-r--r--  1 ryanjbaxter  staff   24 Apr 21 11:16 blueorgreenfrontend-local.yml
-rw-r--r--  1 ryanjbaxter  staff   86 Apr 22 13:46 blueorgreenfrontend.yml
-rw-r--r--  1 ryanjbaxter  staff  108 Apr 21 11:16 blueorgreengateway.yml

For some reason Boot thinks the directory is empty and then throws this exception

java.lang.IllegalStateException: Location 'file:/Users/ryanjbaxter/git-repos/ryanjbaxter/spring-one-tour-2021/gateway-s1p-2018/config-files/*/' must not be a pattern
	at org.springframework.util.Assert.state(Assert.java:97)
	at org.springframework.boot.context.config.LocationResourceLoader.validateNonPattern(LocationResourceLoader.java:84)
	at org.springframework.boot.context.config.LocationResourceLoader.getResource(LocationResourceLoader.java:75)
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolveEmptyDirectories(StandardConfigDataLocationResolver.java:247)
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:237)
	at org.springframework.boot.context.config.StandardConfigDataLocationResolver.resolve(StandardConfigDataLocationResolver.java:115)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.lambda$resolve$1(ConfigDataLocationResolvers.java:115)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:126)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:115)
	at org.springframework.boot.context.config.ConfigDataLocationResolvers.resolve(ConfigDataLocationResolvers.java:107)
	at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:101)
	at org.springframework.boot.context.config.ConfigDataImporter.resolve(ConfigDataImporter.java:93)
	at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:81)
	at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
	at org.springframework.boot.context.config.ConfigDataEnvironment.processInitial(ConfigDataEnvironment.java:242)
	at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:230)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:97)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
	at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
	at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
	at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
	at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
	at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
	at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:375)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:333)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329)
	at org.springframework.demo.BlueOrGreenApplication.main(BlueOrGreenApplication.java:14)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions