You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2023/06/29 11:20:50 UTC

[tomcat] branch main updated: This API should actually not return null

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

remm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 341ee31c3a This API should actually not return null
341ee31c3a is described below

commit 341ee31c3ad0717081715b351a5fbcee6b122753
Author: remm <re...@apache.org>
AuthorDate: Thu Jun 29 13:20:30 2023 +0200

    This API should actually not return null
---
 java/org/apache/catalina/Context.java | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/Context.java b/java/org/apache/catalina/Context.java
index 30f9f3016d..4be9f8f72c 100644
--- a/java/org/apache/catalina/Context.java
+++ b/java/org/apache/catalina/Context.java
@@ -1989,7 +1989,7 @@ public interface Context extends Container, ContextBind {
         if (name.startsWith(WEBAPP_PROTOCOL)) {
             String path = name.substring(WEBAPP_PROTOCOL.length());
             WebResource resource = getResources().getResource(path);
-            if (resource.canRead()) {
+            if (resource.canRead() && resource.isFile()) {
                 InputStream stream = resource.getInputStream();
                 try {
                     return new Resource(stream, resource.getURL().toURI());
@@ -1997,10 +1997,8 @@ public interface Context extends Container, ContextBind {
                     stream.close();
                 }
             }
-            return null;
-        } else {
-            return ConfigFileLoader.getSource().getResource(name);
         }
+        return ConfigFileLoader.getSource().getResource(name);
     }
 
 }


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