Author: kkolinko
Date: Tue Mar  1 23:59:36 2011
New Revision: 1076059

URL: http://svn.apache.org/viewvc?rev=1076059&view=rev
Log:
Improve the fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=48863
1) Be more strict when ignoring the warning:
ignore only when it is the "lib" directory and when it does not exist
2) Warn about JARs created from expanding the GLOB pattern as well
3) s/new File(f.getCanonicalPath())/f.getCanonicalFile()/ for efficiency

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java?rev=1076059&r1=1076058&r2=1076059&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java 
(original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java Tue 
Mar  1 23:59:36 2011
@@ -168,7 +168,7 @@ public final class ClassLoaderFactory {
                     set.add(url);
                 } else if (repository.getType() == RepositoryType.DIR) {
                     File directory = new File(repository.getLocation());
-                    directory = new File(directory.getCanonicalPath());
+                    directory = directory.getCanonicalFile();
                     if (!validateFile(directory, RepositoryType.DIR)) {
                         continue;
                     }
@@ -178,7 +178,7 @@ public final class ClassLoaderFactory {
                     set.add(url);
                 } else if (repository.getType() == RepositoryType.JAR) {
                     File file=new File(repository.getLocation());
-                    file = new File(file.getCanonicalPath());
+                    file = file.getCanonicalFile();
                     if (!validateFile(file, RepositoryType.JAR)) {
                         continue;
                     }
@@ -188,7 +188,7 @@ public final class ClassLoaderFactory {
                     set.add(url);
                 } else if (repository.getType() == RepositoryType.GLOB) {
                     File directory=new File(repository.getLocation());
-                    directory = new File(directory.getCanonicalPath());
+                    directory = directory.getCanonicalFile();
                     if (!validateFile(directory, RepositoryType.GLOB)) {
                         continue;
                     }
@@ -201,9 +201,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, RepositoryType.JAR)) {
                             continue;
+                        }
                         if (log.isDebugEnabled())
                             log.debug("    Including glob jar file "
                                 + file.getAbsolutePath());
@@ -241,14 +242,19 @@ public final class ClassLoaderFactory {
                         "], 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");
 
-                if (!home.getPath().equals(base.getPath()) &&
-                        file.getPath().startsWith(base.getPath())) {
+                // 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);

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1076059&r1=1076058&r2=1076059&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Tue Mar  1 23:59:36 2011
@@ -78,7 +78,7 @@
       </add>
       <fix>
         <bug>48863</bug>: Better logging when specifying an invalid directory
-        for a class loader. Based on a patch by Ralf Hauser. (markt)
+        for a class loader. Based on a patch by Ralf Hauser. (markt/kkolinko)
       </fix>
       <fix>
         <bug>48870</bug>: Refactor to remove use of parallel arrays. (markt)



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

Reply via email to