This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-logging.git
The following commit(s) were added to refs/heads/master by this push: new c2afed5 Raise embedded if into parent if. c2afed5 is described below commit c2afed56ab410c068ee2e5dba045e1dc2e3fc0e6 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Feb 28 12:43:57 2021 -0500 Raise embedded if into parent if. --- .../org/apache/commons/logging/LogFactory.java | 36 ++++++++++------------ .../commons/logging/PathableClassLoader.java | 10 +++--- 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/main/java/org/apache/commons/logging/LogFactory.java b/src/main/java/org/apache/commons/logging/LogFactory.java index 3251541..3d627aa 100644 --- a/src/main/java/org/apache/commons/logging/LogFactory.java +++ b/src/main/java/org/apache/commons/logging/LogFactory.java @@ -419,13 +419,11 @@ public abstract class LogFactory { // Identify the class loader we will be using final ClassLoader contextClassLoader = getContextClassLoaderInternal(); - if (contextClassLoader == null) { - // This is an odd enough situation to report about. This - // output will be a nuisance on JDK1.1, as the system - // classloader is null in that environment. - if (isDiagnosticsEnabled()) { - logDiagnostic("Context classloader is null."); - } + // This is an odd enough situation to report about. This + // output will be a nuisance on JDK1.1, as the system + // classloader is null in that environment. + if (contextClassLoader == null && isDiagnosticsEnabled()) { + logDiagnostic("Context classloader is null."); } // Return any previously registered factory for this class loader @@ -458,19 +456,17 @@ public abstract class LogFactory { ClassLoader baseClassLoader = contextClassLoader; if (props != null) { final String useTCCLStr = props.getProperty(TCCL_KEY); - if (useTCCLStr != null) { - // The Boolean.valueOf(useTCCLStr).booleanValue() formulation - // is required for Java 1.2 compatibility. - if (Boolean.valueOf(useTCCLStr).booleanValue() == false) { - // Don't use current context classloader when locating any - // LogFactory or Log classes, just use the class that loaded - // this abstract class. When this class is deployed in a shared - // classpath of a container, it means webapps cannot deploy their - // own logging implementations. It also means that it is up to the - // implementation whether to load library-specific config files - // from the TCCL or not. - baseClassLoader = thisClassLoader; - } + // The Boolean.valueOf(useTCCLStr).booleanValue() formulation + // is required for Java 1.2 compatibility. + if ((useTCCLStr != null) && (Boolean.valueOf(useTCCLStr).booleanValue() == false)) { + // Don't use current context classloader when locating any + // LogFactory or Log classes, just use the class that loaded + // this abstract class. When this class is deployed in a shared + // classpath of a container, it means webapps cannot deploy their + // own logging implementations. It also means that it is up to the + // implementation whether to load library-specific config files + // from the TCCL or not. + baseClassLoader = thisClassLoader; } } diff --git a/src/test/java/org/apache/commons/logging/PathableClassLoader.java b/src/test/java/org/apache/commons/logging/PathableClassLoader.java index 4744d9a..dc9a03a 100644 --- a/src/test/java/org/apache/commons/logging/PathableClassLoader.java +++ b/src/test/java/org/apache/commons/logging/PathableClassLoader.java @@ -273,12 +273,10 @@ public class PathableClassLoader extends URLClassLoader { filename = filename.substring(lastSlash+1); } - if (filename.startsWith(logicalLib)) { - // ok, this is a candidate - if (filename.length() < shortestMatchLen) { - shortestMatch = u; - shortestMatchLen = filename.length(); - } + // ok, this is a candidate + if (filename.startsWith(logicalLib) && filename.length() < shortestMatchLen) { + shortestMatch = u; + shortestMatchLen = filename.length(); } }