Skip to content
This repository was archived by the owner on Apr 23, 2024. It is now read-only.

Configuration locations for Spring do not allow missing for file URLs #39

@jgibson

Description

@jgibson

When the spring configuration location is specified as a file: URL if it isn't found then it causes an error. classpath: URLs fail gracefully because Spring's ResourceUtils.getURL() throws a FileNotFoundException when the classpath URL can't be resolved. In contrast File URLs only cause that exception when they are invalid as both a URL and as a filepath (something that I was unable to do on a Mac running Java 8, perhaps windows is different).

File URLs should fail gracefully to allow the multiple configuration logic to behave properly, just like they do for classpath URLs.

Caused by: ch.qos.logback.core.joran.spi.JoranException: Could not open URL [file:/Users/foo/bar/logback.xml].
       at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:53)
       at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
       at ch.qos.logback.ext.spring.LogbackConfigurer.initLogging(Unknown Source)
       ... 94 more
Caused by: java.io.FileNotFoundException: /Users/foo/bar/logback.xml (No such file or directory)
       at java.io.FileInputStream.open0(Native Method)
       at java.io.FileInputStream.open(FileInputStream.java:195)
       at java.io.FileInputStream.<init>(FileInputStream.java:138)
       at java.io.FileInputStream.<init>(FileInputStream.java:93)
       at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:90)
       at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:188)
       at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:48)
       ... 96 more

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions