1
0

Reverted 375631 (null getParent). After discussions about the relevant javadocs, it was established that the interpretation which lead to this patch is probably wrong. The original implementation supplies null to Class.forName which should create the class from the boot loader.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@377868 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Burrell Donkin
2006-02-14 22:38:07 +00:00
parent 5a64bf30d6
commit bf61edb4c3

View File

@@ -937,11 +937,6 @@ public class LogFactoryImpl extends LogFactory {
Class logAdapterClass = null;
ClassLoader currentCL = getBaseClassLoader();
//
// This variable is used to ensure that the system classloader
// is tried only once when getParent is null.
boolean systemClassloaderTried = false;
for(;;) {
// Loop through the classloader hierarchy trying to find
// a viable classloader.
@@ -1058,66 +1053,7 @@ public class LogFactoryImpl extends LogFactory {
}
// try the parent classloader
final ClassLoader parentCL = currentCL.getParent();
//
// getParent may return null to indicate that the parent
// is the 'bootstrap classloader'. This term is difficult.
// A reasonable way to interpret this is as
// the system classloader which is provided as a base
// for delegating classloaders.
//
// Note that this functionality cannot be easily tested
// since it depends upon an optional behaviour of the basic
// java libraries. The Sun libraries do not behave in this
// fashion. It may be possible to create a test that
// uses a customized boot classpath containing a special
// implementation but this approach
// would need to wait until an open source Java implementation
// exists. So sadly, this code path is not unit tested.
//
if (parentCL == null) {
if (systemClassloaderTried == true)
{
logDiagnostic("Parent classloader is NULL. But System ClassLoader has already been tried.");
break;
}
// try system classloader
try {
final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
if (systemClassLoader == null) {
logDiagnostic("System classloader is NULL. Cannot find parent of classloader "
+ objectId(currentCL));
break;
} else if (systemClassLoader.equals(currentCL)) {
// the system classloader has already been tried and failed
logDiagnostic("System classloader tried and failed.");
break;
} else {
// the parent is null indicating that the parent is the boot classloader
// so retry with system classloader
currentCL = systemClassLoader;
//
// avoid infinite loops by trying the system loader only the
// first time a classloader
systemClassloaderTried = true;
logDiagnostic("Parent classloader is NULL. Trying System ClassLoader.");
}
} catch (Throwable t) {
// getSystemClassLoader is allowed to fail in
// many strange ways: so need to catch everything
// including errors
logDiagnostic("Failed to get system classloader: '"
+ t.getMessage()
+ "'. Cannot find parent of classloader "
+ objectId(currentCL));
break;
}
} else {
currentCL = parentCL;
}
currentCL = currentCL.getParent();
}
if ((logAdapter != null) && affectState) {