tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1384255 - /tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
Date Thu, 13 Sep 2012 09:40:32 GMT
Author: markt
Date: Thu Sep 13 09:40:31 2012
New Revision: 1384255

URL: http://svn.apache.org/viewvc?rev=1384255&view=rev
Log:
Correct behaviour to take account of webAppMount and internalPath.
Untested. Need some unit tests around all of this.

Modified:
    tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java

Modified: tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
URL: http://svn.apache.org/viewvc/tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java?rev=1384255&r1=1384254&r2=1384255&view=diff
==============================================================================
--- tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
(original)
+++ tomcat/sandbox/trunk-resources/java/org/apache/catalina/webresources/JarResourceSet.java
Thu Sep 13 09:40:31 2012
@@ -74,8 +74,8 @@ public class JarResourceSet implements W
     @Override
     public WebResource getResource(String path) {
         if (path.startsWith(webAppMount)) {
-            StringBuilder pathInJar = new StringBuilder(internalPath);
-            pathInJar.append(path.substring(webAppMount.length()));
+            String pathInJar =
+                    internalPath + path.substring(webAppMount.length());
             JarEntry jarEntry = base.getJarEntry(pathInJar.toString());
             if (jarEntry == null) {
                 return new EmptyResource(root, path);
@@ -96,12 +96,17 @@ public class JarResourceSet implements W
     @Override
     public Set<String> listWebAppPaths(String path) {
         ResourceSet<String> result = new ResourceSet<>();
-        Enumeration<JarEntry> entries = base.entries();
-        while (entries.hasMoreElements()) {
-            JarEntry entry = entries.nextElement();
-            String name = entry.getName();
-            if (name.startsWith(path)) {
-                result.add(name);
+        if (path.startsWith(webAppMount)) {
+            String pathInJar =
+                    internalPath + path.substring(webAppMount.length());
+            Enumeration<JarEntry> entries = base.entries();
+            while (entries.hasMoreElements()) {
+                JarEntry entry = entries.nextElement();
+                String name = entry.getName();
+                if (name.startsWith(pathInJar)) {
+                    result.add(webAppMount +
+                            name.substring(internalPath.length()));
+                }
             }
         }
         result.setLocked(true);



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


Mime
View raw message