From: kkolinko Date: Tue, 1 Mar 2011 23:59:36 +0000 (+0000) Subject: Improve the fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=48863 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=544b6156b2a3dbec77702f9ecf508b1acb1ab73c;p=tomcat7.0 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 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1076059 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/startup/ClassLoaderFactory.java b/java/org/apache/catalina/startup/ClassLoaderFactory.java index 018dc5405..0544f7de1 100644 --- a/java/org/apache/catalina/startup/ClassLoaderFactory.java +++ b/java/org/apache/catalina/startup/ClassLoaderFactory.java @@ -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); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index f94287ed9..4a4289d14 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -78,7 +78,7 @@ 48863: 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) 48870: Refactor to remove use of parallel arrays. (markt)