You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/10/28 02:57:46 UTC
svn commit: r1710924 -
/tomcat/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java
Author: markt
Date: Wed Oct 28 01:57:46 2015
New Revision: 1710924
URL: http://svn.apache.org/viewvc?rev=1710924&view=rev
Log:
Action kkolinko's review comments on r1710445
Remove unnecessary isFile() call and use a FileInputStream for a file rather than going via a URL
Modified:
tomcat/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java
Modified: tomcat/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java?rev=1710924&r1=1710923&r2=1710924&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/util/file/ConfigFileLoader.java Wed Oct 28 01:57:46 2015
@@ -18,6 +18,7 @@
package org.apache.tomcat.util.file;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
@@ -57,31 +58,21 @@ public class ConfigFileLoader {
* provided location
*/
public static InputStream getInputStream(String location) throws IOException {
- // Absolute URIs will be left alone
- // Relative files will be resolved relative to catalina base
- // Absolute files will be converted to URIs
-
- URI uri = null;
-
// Location was originally always a file before URI support was added so
// try file first.
- // First guess, an absolute file path
File f = new File(location);
- if (!f.isFile()) {
- // Second guess, a file path relative to CATALINA_BASE
- if (!f.isAbsolute()) {
- f = new File(CATALINA_BASE_FILE, location);
- }
+ if (!f.isAbsolute()) {
+ f = new File(CATALINA_BASE_FILE, location);
}
if (f.isFile()) {
- uri = f.getAbsoluteFile().toURI();
+ return new FileInputStream(f);
}
- if (uri == null) {
- // Third and final guess, a URI
- uri = CATALINA_BASE_URI.resolve(location);
- }
+ // 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);
// Obtain the input stream we need
URL url = uri.toURL();
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org