You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2011/06/03 10:01:35 UTC

svn commit: r1130932 - in /tomcat/tc6.0.x/trunk: STATUS.txt java/org/apache/catalina/startup/ClassLoaderFactory.java webapps/docs/changelog.xml

Author: markt
Date: Fri Jun  3 08:01:35 2011
New Revision: 1130932

URL: http://svn.apache.org/viewvc?rev=1130932&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48863
Provide an warning if there is a problem with a class path entry but use debug level logging if it is expected due to catalina home/base split

Modified:
    tomcat/tc6.0.x/trunk/STATUS.txt
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
    tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml

Modified: tomcat/tc6.0.x/trunk/STATUS.txt
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/STATUS.txt?rev=1130932&r1=1130931&r2=1130932&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/STATUS.txt (original)
+++ tomcat/tc6.0.x/trunk/STATUS.txt Fri Jun  3 08:01:35 2011
@@ -97,13 +97,6 @@ PATCHES PROPOSED TO BACKPORT:
   +1: kfujino, markt
   -1:
 
-* Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48863
-  Provide an warning if there is a problem with a class path entry but use debug
-  level logging if it is expected due to catalina home/base split
-  http://people.apache.org/~kkolinko/patches/2011-03-02_tc6_48863.patch
-  +1: kkolinko, markt, schultz
-  -1:
-
 * Fix possible threading issue in JSP compilation when development mode is
   enabled
   http://svn.apache.org/viewvc?rev=1078409&view=rev

Modified: tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java?rev=1130932&r1=1130931&r2=1130932&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java Fri Jun  3 08:01:35 2011
@@ -20,6 +20,7 @@ package org.apache.catalina.startup;
 
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
 import java.util.LinkedHashSet;
 import java.util.Set;
@@ -198,28 +199,30 @@ public final class ClassLoaderFactory {
                     set.add(url);
                 } else if ( types[i] == IS_DIR ) {
                     File directory = new File(location);
-                    directory = new File(directory.getCanonicalPath());
-                    if (!directory.exists() || !directory.isDirectory() ||
-                        !directory.canRead())
-                         continue;
+                    directory = directory.getCanonicalFile();
+                    if (!validateFile(directory, IS_DIR)) {
+                        continue;
+                    }
                     URL url = directory.toURI().toURL();
                     if (log.isDebugEnabled())
                         log.debug("  Including directory " + url);
                     set.add(url);
                 } else if ( types[i] == IS_JAR ) {
                     File file=new File(location);
-                    file = new File(file.getCanonicalPath());
-                    if (!file.exists() || !file.canRead())
+                    file = file.getCanonicalFile();
+                    if (!validateFile(file, IS_JAR)) {
                         continue;
+                    }
                     URL url = file.toURI().toURL();
                     if (log.isDebugEnabled())
                         log.debug("  Including jar file " + url);
                     set.add(url);
                 } else if ( types[i] == IS_GLOB ) {
                     File directory=new File(location);
-                    if (!directory.exists() || !directory.isDirectory() ||
-                        !directory.canRead())
+                    directory = directory.getCanonicalFile();
+                    if (!validateFile(directory, IS_GLOB)) {
                         continue;
+                    }
                     if (log.isDebugEnabled())
                         log.debug("  Including directory glob "
                             + directory.getAbsolutePath());
@@ -229,9 +232,10 @@ public final class ClassLoaderFactory {
                         if (!filename.endsWith(".jar"))
                             continue;
                         File file = new File(directory, filenames[j]);
-                        file = new File(file.getCanonicalPath());
-                        if (!file.exists() || !file.canRead())
+                        file = file.getCanonicalFile();
+                        if (!validateFile(file, IS_JAR)) {
                             continue;
+                        }
                         if (log.isDebugEnabled())
                             log.debug("    Including glob jar file "
                                 + file.getAbsolutePath());
@@ -257,5 +261,41 @@ public final class ClassLoaderFactory {
 
     }
 
-
+    private static boolean validateFile(File file,
+            Integer type) throws IOException {
+        if (type == IS_DIR || type == IS_GLOB) {
+            if (!file.exists() || !file.isDirectory() || !file.canRead()) {
+                String msg = "Problem with directory [" + file +
+                        "], exists: [" + file.exists() +
+                        "], isDirectory: [" + file.isDirectory() +
+                        "], canRead: [" + file.canRead() + "]";
+
+                File home = new File (Bootstrap.getCatalinaHome());
+                home = home.getCanonicalFile();
+                File base = new File (Bootstrap.getCatalinaBase());
+                base = base.getCanonicalFile();
+                File defaultValue = new File(base, "lib");
+
+                // Existence of ${catalina.base}/lib directory is optional.
+                // Hide the warning if Tomcat runs with separate catalina.home
+                // and catalina.base and that directory is absent.
+                if (!home.getPath().equals(base.getPath())
+                        && file.getPath().equals(defaultValue.getPath())
+                        && !file.exists()) {
+                    log.debug(msg);
+                } else {
+                    log.warn(msg);
+                }
+                return false;
+            }
+        } else if (type == IS_JAR) {
+            if (!file.exists() || !file.canRead()) {
+                log.warn("Problem with JAR file [" + file +
+                        "], exists: [" + file.exists() +
+                        "], canRead: [" + file.canRead() + "]");
+                return false;
+            }
+        }
+        return true;
+    }
 }

Modified: tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml?rev=1130932&r1=1130931&r2=1130932&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc6.0.x/trunk/webapps/docs/changelog.xml Fri Jun  3 08:01:35 2011
@@ -55,6 +55,11 @@
         Stephane Bailliez. (markt) 
       </fix>
       <add>
+        <bug>48863</bug>: Provide an warning if there is a problem with a class
+        path entry but use debug level logging if it is expected due to catalina
+        home/base split. (kkolinko)
+      </add>
+      <add>
         <bug>49180</bug>: Add an option to disable file rotation in JULI
         FileHandler. (kkolinko)
       </add>



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