[tomcat] branch master updated: Correct regression in loading of config files via URIs on Windows.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[tomcat] branch master updated: Correct regression in loading of config files via URIs on Windows.

markt
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 e652925  Correct regression in loading of config files via URIs on Windows.
e652925 is described below

commit e6529257ce5190b9c28c1102f1e0f277f1892ac8
Author: Mark Thomas <[hidden email]>
AuthorDate: Thu May 21 10:32:10 2020 +0100

    Correct regression in loading of config files via URIs on Windows.
---
 .../startup/CatalinaBaseConfigurationSource.java     | 20 ++++++++++++--------
 webapps/docs/changelog.xml                           |  4 ++++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java
index 53fb91f..51615bb 100644
--- a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java
+++ b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java
@@ -90,17 +90,21 @@ public class CatalinaBaseConfigurationSource implements ConfigurationSource {
         }
 
         // Try classloader
-        InputStream stream = getClass().getClassLoader().getResourceAsStream(name);
-        if (stream != null) {
-            try {
+        InputStream stream = null;
+        try {
+            stream = getClass().getClassLoader().getResourceAsStream(name);
+            if (stream != null) {
                 return new Resource(stream, getClass().getClassLoader().getResource(name).toURI());
-            } catch (InvalidPathException e) {
-                // Ignore. Some valid file URIs can trigger this.
-                stream.close();
-            } catch (URISyntaxException e) {
+            }
+        } catch (InvalidPathException e) {
+            // Ignore. Some valid file URIs can trigger this.
+            // Stream should be null here but check to be on the safe side.
+            if (stream != null) {
                 stream.close();
-                throw new IOException(sm.getString("catalinaConfigurationSource.cannotObtainURL", name), e);
             }
+        } catch (URISyntaxException e) {
+            stream.close();
+            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 57c981c..38f200d 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -60,6 +60,10 @@
         Add the special internal rewrite maps for case modification and
         escaping. (remm/fschumacher)
       </update>
+      <fix>
+        Correct a regression in an earlier fix that broke the loading of
+        configuration files such as keystores via URIs on Windows. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]