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 2021/01/28 15:55:59 UTC

[tomcat] branch 9.0.x updated: Refactor getResource() to avoid calling tests twice

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 42636a9  Refactor getResource() to avoid calling tests twice
42636a9 is described below

commit 42636a99d96a51ce02818660c412dfa4f8c6f7d1
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jan 28 15:55:08 2021 +0000

    Refactor getResource() to avoid calling tests twice
    
    If the path passed to getResource() was a URI it was checked to see if
    it was a file or a classloader resource twice. Once in getResource() and
    once in getURI().
---
 .../apache/catalina/startup/CatalinaBaseConfigurationSource.java   | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java
index 51615bb..90ebed7 100644
--- a/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java
+++ b/java/org/apache/catalina/startup/CatalinaBaseConfigurationSource.java
@@ -110,7 +110,7 @@ public class CatalinaBaseConfigurationSource implements ConfigurationSource {
         // Then try URI.
         URI uri = null;
         try {
-            uri = getURI(name);
+            uri = getURIInternal(name);
         } catch (IllegalArgumentException e) {
             throw new IOException(sm.getString("catalinaConfigurationSource.cannotObtainURL", name), e);
         }
@@ -144,6 +144,10 @@ public class CatalinaBaseConfigurationSource implements ConfigurationSource {
             // Ignore
         }
 
+        return getURIInternal(name);
+    }
+
+    private URI getURIInternal(String name) {
         // Then try URI.
         // Using resolve() enables the code to handle relative paths that did
         // not point to a file
@@ -155,5 +159,4 @@ public class CatalinaBaseConfigurationSource implements ConfigurationSource {
         }
         return uri;
     }
-
 }


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