You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Possible bug is the PSPConfigurer not catching the right exception when the setIgnoreResourceNotFound option is true.
I got java.nio.file.NoSuchFileException but it only catches java.io.FIleNotFoundException.
Running environment:
Java: jdk1.8.0_144
Kotlin: 1.2.10
Running with Spring Boot v2.0.0.M7, Spring v5.0.2.RELEASE
@Bean
open fun propertyPlaceholderConfigurer(): PropertySourcesPlaceholderConfigurer {
return PropertySourcesPlaceholderConfigurer().apply {
setIgnoreResourceNotFound(true)
order = Ordered.HIGHEST_PRECEDENCE
setLocations(
ClassPathResource("default.properties"),
FileSystemResource("${user.home}/desktop.properties")
)
}
}
This is the exception stack:
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.nio.file.NoSuchFileException: /Users/dev/desktop.properties
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:153)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:284)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:164)
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:693)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:138)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:751)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:387)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:136)
at hu.hobbesmedia.legenda.cassa.BootstrapKt.main(Bootstrap.kt:79)
Caused by: java.nio.file.NoSuchFileException: /Users/dev/desktop.properties
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at org.springframework.core.io.FileSystemResource.getInputStream(FileSystemResource.java:123)
at org.springframework.core.io.support.EncodedResource.getInputStream(EncodedResource.java:159)
at org.springframework.core.io.support.PropertiesLoaderUtils.fillProperties(PropertiesLoaderUtils.java:99)
at org.springframework.core.io.support.PropertiesLoaderSupport.loadProperties(PropertiesLoaderSupport.java:181)
at org.springframework.core.io.support.PropertiesLoaderSupport.mergeProperties(PropertiesLoaderSupport.java:162)
at org.springframework.context.support.PropertySourcesPlaceholderConfigurer.postProcessBeanFactory(PropertySourcesPlaceholderConfigurer.java:144)
Our resource abstraction consistently throws FileNotFoundException even for NIO access now, following its original javadoc contract. This makes existing catch (FileNotFoundException) clauses work as before.
Our team are glad that you find a solution for this. Thank you for the fast respond and of course for your hard work on this awesome framework.
Keep up with the good work =)
Attila Turcsan opened SPR-16334 and commented
Possible bug is the PSPConfigurer not catching the right exception when the setIgnoreResourceNotFound option is true.
I got java.nio.file.NoSuchFileException but it only catches java.io.FIleNotFoundException.
Running environment:
Java: jdk1.8.0_144
Kotlin: 1.2.10
Running with Spring Boot v2.0.0.M7, Spring v5.0.2.RELEASE
This is the exception stack:
Affects: 5.0.2
Issue Links:
Referenced from: commits 1a154c3
The text was updated successfully, but these errors were encountered: