diff --git a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java index 9cd399f..85df26b 100644 --- a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -688,6 +688,28 @@ public class LogFactoryImpl extends LogFactory { }); } + /** + * Fetch the parent classloader of a specified classloader. + *
+ * If a SecurityException occurs, null is returned. + *
+ * Note that this method is non-static merely so logDiagnostic is available. + */ + private ClassLoader getParentClassLoader(final ClassLoader cl) { + try { + return (ClassLoader)AccessController.doPrivileged( + new PrivilegedAction() { + public Object run() { + return cl.getParent(); + } + }); + } catch(SecurityException ex) { + logDiagnostic("[SECURITY] Unable to obtain parent classloader"); + return null; + } + + } + /** * Utility method to check whether a particular logging library is * present and available for use. Note that this does not @@ -1161,7 +1183,8 @@ public class LogFactoryImpl extends LogFactory { } // try the parent classloader - currentCL = currentCL.getParent(); + // currentCL = currentCL.getParent(); + currentCL = getParentClassLoader(currentCL); } if ((logAdapter != null) && affectState) {