You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by vi...@apache.org on 2016/03/22 20:32:00 UTC

svn commit: r1736238 - in /tomcat/tc8.5.x/trunk: ./ java/org/apache/tomcat/util/file/ConfigFileLoader.java java/org/apache/tomcat/util/file/LocalStrings.properties webapps/docs/changelog.xml

Author: violetagg
Date: Tue Mar 22 19:32:00 2016
New Revision: 1736238

URL: http://svn.apache.org/viewvc?rev=1736238&view=rev
Log:
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=59206
Merged revision 1736209 from tomcat/trunk:
Ensure NPE will not be thrown by when catalina.base is not specified.

Added:
    tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties
      - copied unchanged from r1736209, tomcat/trunk/java/org/apache/tomcat/util/file/LocalStrings.properties
Modified:
    tomcat/tc8.5.x/trunk/   (props changed)
    tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java
    tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc8.5.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Mar 22 19:32:00 2016
@@ -1 +1 @@
-/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162
+/tomcat/trunk:1734785,1734799,1734845,1734928,1735041,1735044,1735480,1735577,1735597,1735599-1735600,1735615,1736145,1736162,1736209

Modified: tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java?rev=1736238&r1=1736237&r2=1736238&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java (original)
+++ tomcat/tc8.5.x/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java Tue Mar 22 19:32:00 2016
@@ -24,6 +24,8 @@ import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
 
+import org.apache.tomcat.util.res.StringManager;
+
 /**
  * This class is used to obtain {@link InputStream}s for configuration files
  * from a given location String. This allows greater flexibility than these
@@ -31,12 +33,21 @@ import java.net.URL;
  */
 public class ConfigFileLoader {
 
+    private static final StringManager sm = StringManager.getManager(ConfigFileLoader.class
+            .getPackage().getName());
+
     private static final File CATALINA_BASE_FILE;
     private static final URI CATALINA_BASE_URI;
 
     static {
-        CATALINA_BASE_FILE = new File(System.getProperty("catalina.base"));
-        CATALINA_BASE_URI = CATALINA_BASE_FILE.toURI();
+        String catalinaBase = System.getProperty("catalina.base");
+        if (catalinaBase != null) {
+            CATALINA_BASE_FILE = new File(catalinaBase);
+            CATALINA_BASE_URI = CATALINA_BASE_FILE.toURI();
+        } else {
+            CATALINA_BASE_FILE = null;
+            CATALINA_BASE_URI = null;
+        }
     }
 
     private ConfigFileLoader() {
@@ -72,10 +83,19 @@ public class ConfigFileLoader {
         // File didn't work so try URI.
         // Using resolve() enables the code to handle relative paths that did
         // not point to a file
-        URI uri = CATALINA_BASE_URI.resolve(location);
+        URI uri;
+        if (CATALINA_BASE_URI != null) {
+            uri = CATALINA_BASE_URI.resolve(location);
+        } else {
+            uri = URI.create(location);
+        }
 
         // Obtain the input stream we need
-        URL url = uri.toURL();
-        return url.openConnection().getInputStream();
+        try {
+            URL url = uri.toURL();
+            return url.openConnection().getInputStream();
+        } catch (IllegalArgumentException e) {
+            throw new IOException(sm.getString("configFileLoader.cannotObtainURL", location), e);
+        }
     }
 }

Modified: tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml?rev=1736238&r1=1736237&r2=1736238&view=diff
==============================================================================
--- tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc8.5.x/trunk/webapps/docs/changelog.xml Tue Mar 22 19:32:00 2016
@@ -45,6 +45,15 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 8.5.1" rtext="In development">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        <bug>59206</bug>: Ensure NPE will not be thrown by
+        <code>o.a.tomcat.util.file.ConfigFileLoader</code> when
+        <code>catalina.base</code> is not specified. (violetagg)
+      </fix>
+    </changelog>
+  </subsection>
   <subsection name="WebSocket">
     <changelog>
       <fix>



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org