Author: markt Date: Mon Feb 28 13:35:41 2011 New Revision: 1075320 URL: http://svn.apache.org/viewvc?rev=1075320&view=rev Log: Improve fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=48863 - consistently pass absolute paths to validateFile() - handle non-absolute catalina home/base
Modified: tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java 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=1075320&r1=1075319&r2=1075320&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java (original) +++ tomcat/trunk/java/org/apache/catalina/startup/ClassLoaderFactory.java Mon Feb 28 13:35:41 2011 @@ -20,6 +20,7 @@ package org.apache.catalina.startup; import java.io.File; +import java.io.IOException; import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; @@ -187,6 +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()); if (!validateFile(directory, RepositoryType.GLOB)) { continue; } @@ -232,20 +234,21 @@ public final class ClassLoaderFactory { } private static boolean validateFile(File file, - RepositoryType type) { + RepositoryType type) throws IOException { if (RepositoryType.DIR == type || RepositoryType.GLOB == type) { if (!file.exists() || !file.isDirectory() || !file.canRead()) { - String msg = "Problem with directory [" + - file.getAbsolutePath() + "], exists: [" + - file.exists() + "], isDirectory: [" + - file.isDirectory() + "], canRead: [" + - file.canRead() + "]"; + String msg = "Problem with directory [" + file + + "], exists: [" + file.exists() + + "], isDirectory: [" + file.isDirectory() + + "], canRead: [" + file.canRead() + "]"; - if (!Bootstrap.getCatalinaHome().equals( - Bootstrap.getCatalinaBase()) && - file.getAbsolutePath().startsWith( - Bootstrap.getCatalinaBase())) { - + File home = new File (Bootstrap.getCatalinaHome()); + home = home.getCanonicalFile(); + File base = new File (Bootstrap.getCatalinaBase()); + base = base.getCanonicalFile(); + + if (!home.getPath().equals(base.getPath()) && + file.getPath().startsWith(base.getPath())) { log.debug(msg); } else { log.warn(msg); @@ -254,10 +257,9 @@ public final class ClassLoaderFactory { } } else if (RepositoryType.JAR == type) { if (!file.exists() || !file.canRead()) { - log.warn("Problem with JAR file [" + - file.getAbsolutePath() + "], exists: [" + - file.exists() + "], canRead: [" + - file.canRead() + "]"); + log.warn("Problem with JAR file [" + file + + "], exists: [" + file.exists() + + "], canRead: [" + file.canRead() + "]"); return false; } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org