Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50997
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 30 Mar 2011 20:06:25 +0000 (20:06 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 30 Mar 2011 20:06:25 +0000 (20:06 +0000)
Relax the requirement that directories must have a name ending in .jar to be treated as an expanded JAR file by the default JarScanner.
Based on patch by Rodion Zhitomirsky.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1087062 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/startup/ContextConfig.java
java/org/apache/tomcat/util/scan/StandardJarScanner.java
webapps/docs/changelog.xml

index a638767..76fec6c 100644 (file)
@@ -2347,7 +2347,7 @@ public class ContextConfig
         public void scan(File file) throws IOException {
 
             InputStream stream = null;
-            WebXml fragment = null;
+            WebXml fragment = new WebXml();
             
             try {
                 File fragmentFile = new File(file, FRAGMENT_LOCATION);
@@ -2356,7 +2356,6 @@ public class ContextConfig
                     InputSource source =
                         new InputSource(fragmentFile.toURI().toURL().toString());
                     source.setByteStream(stream);
-                    fragment = new WebXml();
                     parseWebXml(source, fragment, true);
                 }
             } finally {
@@ -2367,15 +2366,11 @@ public class ContextConfig
                         ExceptionUtils.handleThrowable(t);
                     }
                 }
-                if (fragment == null) {
-                    fragments.put(file.toURI().toURL().toString(), fragment);
-                } else {
-                    fragment.setURL(file.toURI().toURL());
-                    if (fragment.getName() == null) {
-                        fragment.setName(fragment.getURL().toString());
-                    }
-                    fragments.put(fragment.getName(), fragment);
+                fragment.setURL(file.toURI().toURL());
+                if (fragment.getName() == null) {
+                    fragment.setName(fragment.getURL().toString());
                 }
+                fragments.put(fragment.getName(), fragment);
             }
         }
         
index 769bc25..546b073 100644 (file)
@@ -271,6 +271,9 @@ public class StandardJarScanner implements JarScanner {
         if (end != -1) {
             int start = path.lastIndexOf('/', end);
             name = path.substring(start + 1, end + 4);
+        } else if (isScanAllDirectories()){
+            int start = path.lastIndexOf('/');
+            name = path.substring(start + 1);
         }
         
         return name;
index cdcb078..a74e363 100644 (file)
         Correctly track changes to context.xml files and trigger redeployment
         when copyXML is set to false. (markt) 
       </fix>
+      <fix>
+        <bug>50997</bug>: Relax the requirement that directories must have a
+        name ending in <code>.jar</code> to be treated as an expanded JAR file
+        by the default JarScanner. Based on patch by Rodion Zhitomirsky. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">