From 7c13eff4f5c342ce4926880aca25a9b8ba3b8ab6 Mon Sep 17 00:00:00 2001 From: markt Date: Mon, 28 Feb 2011 13:35:41 +0000 Subject: [PATCH] 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 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1075320 13f79535-47bb-0310-9956-ffa450edef68 --- .../catalina/startup/ClassLoaderFactory.java | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/java/org/apache/catalina/startup/ClassLoaderFactory.java b/java/org/apache/catalina/startup/ClassLoaderFactory.java index eea0cc371..018dc5405 100644 --- a/java/org/apache/catalina/startup/ClassLoaderFactory.java +++ b/java/org/apache/catalina/startup/ClassLoaderFactory.java @@ -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; } } -- 2.11.0