* Fix minor syntax error in previous checkin (oops).
* Improve error message when custom LogFactory class cannot be instantiated due to class cast issues. git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@381886 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -465,7 +465,7 @@ public abstract class LogFactory {
|
|||||||
+ "]. Trying alternative implementations...");
|
+ "]. Trying alternative implementations...");
|
||||||
}
|
}
|
||||||
; // ignore
|
; // ignore
|
||||||
} catch(Exception e) {
|
} catch(RuntimeException e) {
|
||||||
// This is not consistent with the behaviour when a bad LogFactory class is
|
// This is not consistent with the behaviour when a bad LogFactory class is
|
||||||
// specified in a services file.
|
// specified in a services file.
|
||||||
//
|
//
|
||||||
@@ -1096,15 +1096,23 @@ public abstract class LogFactory {
|
|||||||
// ignore exception, continue
|
// ignore exception, continue
|
||||||
} catch(ClassCastException e) {
|
} catch(ClassCastException e) {
|
||||||
if (classLoader == thisClassLoader) {
|
if (classLoader == thisClassLoader) {
|
||||||
// This cast exception is not due to classloader issues;
|
// There's no point in falling through to the code below that
|
||||||
// the specified class *really* doesn't extend the
|
// tries again with thisClassLoader, because we've just tried
|
||||||
// required LogFactory base class.
|
// loading with that loader (not the TCCL). Just throw an
|
||||||
|
// appropriate exception here.
|
||||||
|
|
||||||
|
String msg =
|
||||||
|
"Class '" + factoryClass + "' cannot be converted to '"
|
||||||
|
+ LogFactory.class.getName() + "'."
|
||||||
|
+ " Perhaps you have multiple copies of LogFactory in "
|
||||||
|
+ " the classpath?";
|
||||||
|
|
||||||
if (isDiagnosticsEnabled()) {
|
if (isDiagnosticsEnabled()) {
|
||||||
logDiagnostic(
|
logDiagnostic(msg);
|
||||||
"Class '" + factoryClass + "' really does not extend '"
|
|
||||||
+ LogFactory.class.getName() + "'");
|
|
||||||
}
|
}
|
||||||
throw e;
|
|
||||||
|
ClassCastException ex = new ClassCastException(msg);
|
||||||
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore exception, continue. Presumably the classloader was the
|
// Ignore exception, continue. Presumably the classloader was the
|
||||||
|
|||||||
Reference in New Issue
Block a user