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:40 UTC

[tomcat] branch master 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 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 43581c6  Refactor getResource() to avoid calling tests twice
43581c6 is described below

commit 43581c6908745c7d4cfa232ac45e22c37009e0d2
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