This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new ccabf8e Avoid possible Exception ccabf8e is described below commit ccabf8e9afa3858f34938a5163f0ce14491ba631 Author: Mark Thomas <ma...@apache.org> AuthorDate: Sat Aug 17 17:24:50 2019 +0100 Avoid possible Exception Originally reported at https://github.com/spring-projects/spring-boot/issues/17841 --- .../catalina/startup/CatalinaBaseConfigurationSource.java | 13 +++++++------ webapps/docs/changelog.xml | 8 ++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java index 991c932..9c3e208 100644 --- a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java +++ b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java @@ -24,6 +24,7 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.InvalidPathException; import org.apache.tomcat.util.file.ConfigurationSource; import org.apache.tomcat.util.res.StringManager; @@ -88,14 +89,14 @@ public class CatalinaBaseConfigurationSource implements ConfigurationSource { } // Try classloader - InputStream stream = getClass().getClassLoader().getResourceAsStream(name); - if (stream != null) { - try { + try(InputStream stream = getClass().getClassLoader().getResourceAsStream(name)) { + if (stream != null) { return new Resource(stream, getClass().getClassLoader().getResource(name).toURI()); - } catch (URISyntaxException e) { - stream.close(); - throw new IOException(sm.getString("catalinaConfigurationSource.cannotObtainURL", name), e); } + } catch (InvalidPathException e) { + // Ignore. Some valid file URIs can trigger this. + } catch (URISyntaxException e) { + throw new IOException(sm.getString("catalinaConfigurationSource.cannotObtainURL", name), e); } // Then try URI. diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index de1bcc3..83d093d 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -45,6 +45,14 @@ issues do not "pop up" wrt. others). --> <section name="Tomcat 9.0.25 (markt)" rtext="in development"> + <subsection name="Catalina"> + <changelog> + <fix> + Avoid a possible <code>InvalidPathException</code> when obtaining a URI + for a configuration file. (markt) + </fix> + </changelog> + </subsection> <subsection name="Web applications"> <changelog> <fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org