Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConfigDataLocationNotFoundException is thrown for empty files #24515

Closed
philwebb opened this issue Dec 15, 2020 · 3 comments
Closed

ConfigDataLocationNotFoundException is thrown for empty files #24515

philwebb opened this issue Dec 15, 2020 · 3 comments
Assignees
Labels
status: duplicate A duplicate of another issue

Comments

@philwebb
Copy link
Member

touch /Users/pwebb/projects/spring-boot/samples/application.properties
java -jar propbug-0.0.1-SNAPSHOT.jar --spring.config.location=classpath:/application.properties,file:/Users/pwebb/projects/spring-boot/samples/application.properties
08:08:15.231 [main] DEBUG org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - Application failed to start due to an exception
org.springframework.boot.context.config.ConfigDataLocationNotFoundException: Config data location 'file:/Users/pwebb/projects/spring-boot/samples/application.properties' cannot be found
	at org.springframework.boot.context.config.ConfigDataEnvironment.checkMandatoryLocations(ConfigDataEnvironment.java:344)
	at org.springframework.boot.context.config.ConfigDataEnvironment.applyToEnvironment(ConfigDataEnvironment.java:300)
	at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:224)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:88)
	at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:80)
	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:172)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139)
	at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127)
	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:1541)
	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:362)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1309)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1298)
	at com.example.propbug.PropbugApplication.main(PropbugApplication.java:10)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:107)
	at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
	at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88)
08:08:15.234 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - 

***************************
APPLICATION FAILED TO START
***************************

Description:

Config data location 'file:/Users/pwebb/projects/spring-boot/samples/application.properties' does not exist

Action:

Check that the value 'file:/Users/pwebb/projects/spring-boot/samples/application.properties' is correct, or prefix it with 'optional:'
@philwebb philwebb added the type: regression A regression from a previous release label Dec 15, 2020
@philwebb philwebb added this to the 2.4.x milestone Dec 15, 2020
@philwebb philwebb self-assigned this Dec 15, 2020
@philwebb philwebb changed the title ConfigDataLocationNotFoundException is thrown for file that exists ConfigDataLocationNotFoundException is thrown for empty files Dec 15, 2020
@philwebb
Copy link
Member Author

The fix for #24499 has also solved the exception, but I think the root cause is actually our OriginTrackedPropertiesLoader updates. We used to return an PropertySource for empty files and now we don't.

@philwebb
Copy link
Member Author

Actually, we used to filter out empty ones in 2.3 as well.

philwebb added a commit that referenced this issue Dec 15, 2020
Add an additional test to ensure that empty property files do not
throw ConfigDataLocationNotFoundException exceptions.

See gh-24499
See gh-24515
@philwebb
Copy link
Member Author

I'm going to mark this one as a duplicate of #24499, but I've added a test to make sure it doesn't return.

@philwebb philwebb removed this from the 2.4.x milestone Dec 15, 2020
@philwebb philwebb added status: duplicate A duplicate of another issue and removed type: regression A regression from a previous release labels Dec 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

1 participant