Author: markt
Date: Mon Jul 20 16:28:27 2009
New Revision: 795902

URL: http://svn.apache.org/viewvc?rev=795902&view=rev
Log:
Revert the TldConfig part of r795860. It appears to have introduced 
intermittent TCK failures. 

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java

Modified: tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java?rev=795902&r1=795901&r2=795902&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/TldConfig.java Mon Jul 20 
16:28:27 2009
@@ -29,7 +29,6 @@
 import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 import java.util.StringTokenizer;
 import java.util.jar.JarEntry;
@@ -39,7 +38,6 @@
 import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 import javax.naming.directory.DirContext;
-import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
 
 import org.apache.catalina.Context;
@@ -333,7 +331,7 @@
         tldScanWebXml();
         
         // Stage 3a - TLDs under WEB-INF (not lib or classes)
-        tldScanResourcePaths(WEB_INF);
+        tldScanResourcePaths(context.getResources(), WEB_INF);
 
         // Stage 3b - .jar files in WEB-INF/lib/
         tldScanWebInfLib();
@@ -401,51 +399,51 @@
     }
     
     /*
-     * Scans the web application's sub-directory identified by rootPath,
-     * along with its sub-directories, for TLDs.
+     * Scans the web application's subdirectory identified by rootPath,
+     * along with its subdirectories, for TLDs.
      *
      * Initially, rootPath equals /WEB-INF/. The /WEB-INF/classes and
-     * /WEB-INF/lib sub-directories are excluded from the search, as per the
+     * /WEB-INF/lib subdirectories are excluded from the search, as per the
      * JSP 2.0 spec.
      *
-     * @param startPath The path whose sub-directories are to be searched for
+     * @param resources The web application's resources
+     * @param rootPath The path whose subdirectories are to be searched for
      * TLDs
-     * 
-     * Keep code in sync with o.a.j.compiler.TldLocationsCache
      */
-    private void tldScanResourcePaths(String startPath) {
+    private void tldScanResourcePaths(DirContext resources,
+                                            String rootPath) {
 
         if (log.isTraceEnabled()) {
-            log.trace(sm.getString("tldConfig.webinfScan", startPath));
+            log.trace(sm.getString("tldConfig.webinfScan", rootPath));
         }
 
-        ServletContext ctxt = getContext().getServletContext();
-        
-        Set<String> dirList = ctxt.getResourcePaths(startPath);
-        if (dirList != null) {
-            Iterator<String> it = dirList.iterator();
-            while (it.hasNext()) {
-                String path = it.next();
-                if (!path.endsWith(TLD_EXT)
-                        && (path.startsWith("/WEB-INF/lib/")
-                                || path.startsWith("/WEB-INF/classes/"))) {
+        try {
+            NamingEnumeration<NameClassPair> items = resources.list(rootPath);
+            while (items.hasMoreElements()) {
+                NameClassPair item = items.nextElement();
+                String resourcePath = rootPath + item.getName();
+                if (!resourcePath.endsWith(TLD_EXT)
+                        && (resourcePath.equals("/WEB-INF/classes")
+                            || resourcePath.equals("/WEB-INF/lib"))) {
                     continue;
                 }
-                if (path.endsWith(".tld")) {
-                    if (path.startsWith("/WEB-INF/tags/") &&
-                            !path.endsWith("implicit.tld")) {
+                if (resourcePath.endsWith(TLD_EXT)) {
+                    if (resourcePath.startsWith("/WEB-INF/tags") &&
+                            !resourcePath.endsWith("implicit.tld")) {
                         continue;
                     }
                     try {
-                        tldScanTld(path);
+                        tldScanTld(resourcePath);
                     } catch (Exception e) {
                         log.warn(sm.getString(
-                                "tldConfig.webinfFail", path),e);
+                                "tldConfig.webinfFail", resourcePath),e);
                     }
                 } else {
-                    tldScanResourcePaths(path);
+                    tldScanResourcePaths(resources, resourcePath + '/');
                 }
             }
+        } catch (NamingException e) {
+            // Silent catch: it's valid that no /WEB-INF directory exists
         }
     }
     



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

Reply via email to