struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [3/3] struts git commit: Adds double check if resource exists
Date Wed, 17 Aug 2016 14:17:44 GMT
Adds double check if resource exists


Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/c1869f49
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/c1869f49
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/c1869f49

Branch: refs/heads/master
Commit: c1869f4989942dd33fa4e189e0ac1f766fb5ac14
Parents: 17d5e39
Author: Lukasz Lenart <lukaszlenart@apache.org>
Authored: Wed Aug 17 15:35:11 2016 +0200
Committer: Lukasz Lenart <lukaszlenart@apache.org>
Committed: Wed Aug 17 16:17:26 2016 +0200

----------------------------------------------------------------------
 .../convention/ConventionUnknownHandler.java        | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts/blob/c1869f49/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
----------------------------------------------------------------------
diff --git a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
index ace9446..cb10f1b 100644
--- a/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
+++ b/plugins/convention/src/main/java/org/apache/struts2/convention/ConventionUnknownHandler.java
@@ -36,6 +36,12 @@ import org.apache.logging.log4j.Logger;
 import javax.servlet.ServletContext;
 import java.net.MalformedURLException;
 import java.util.*;
+import java.net.URL;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -313,16 +319,18 @@ public class ConventionUnknownHandler implements UnknownHandler {
         try {
             LOG.trace("Checking ServletContext for {}", path);
 
-            if (servletContext.getResource(path) != null) {
-                LOG.trace("Found");
+            URL resource = servletContext.getResource(path);
+            if (resource != null && resource.getPath().endsWith(path)) {
+                LOG.trace("Found resource {}", resource);
                 return buildResult(path, resultCode, resultsByExtension.get(ext), actionContext);
             }
 
             LOG.trace("Checking ClassLoader for {}", path);
 
             String classLoaderPath = path.startsWith("/") ? path.substring(1, path.length())
: path;
-            if (ClassLoaderUtil.getResource(classLoaderPath, getClass()) != null) {
-                LOG.trace("Found");
+            resource = ClassLoaderUtil.getResource(classLoaderPath, getClass());
+            if (resource != null && resource.getPath().endsWith(classLoaderPath))
{
+                LOG.trace("Found resource {}", resource);
                 return buildResult(path, resultCode, resultsByExtension.get(ext), actionContext);
             }
         } catch (MalformedURLException e) {


Mime
View raw message