You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sk...@apache.org on 2006/03/01 04:11:43 UTC
svn commit: r381886 -
/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
Author: skitching
Date: Tue Feb 28 19:11:41 2006
New Revision: 381886
URL: http://svn.apache.org/viewcvs?rev=381886&view=rev
Log:
* Fix minor syntax error in previous checkin (oops).
* Improve error message when custom LogFactory class cannot be instantiated due
to class cast issues.
Modified:
jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
Modified: jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java?rev=381886&r1=381885&r2=381886&view=diff
==============================================================================
--- jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java (original)
+++ jakarta/commons/proper/logging/trunk/src/java/org/apache/commons/logging/LogFactory.java Tue Feb 28 19:11:41 2006
@@ -465,7 +465,7 @@
+ "]. Trying alternative implementations...");
}
; // ignore
- } catch(Exception e) {
+ } catch(RuntimeException e) {
// This is not consistent with the behaviour when a bad LogFactory class is
// specified in a services file.
//
@@ -1096,15 +1096,23 @@
// ignore exception, continue
} catch(ClassCastException e) {
if (classLoader == thisClassLoader) {
- // This cast exception is not due to classloader issues;
- // the specified class *really* doesn't extend the
- // required LogFactory base class.
+ // There's no point in falling through to the code below that
+ // tries again with thisClassLoader, because we've just tried
+ // 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()) {
- logDiagnostic(
- "Class '" + factoryClass + "' really does not extend '"
- + LogFactory.class.getName() + "'");
+ logDiagnostic(msg);
}
- throw e;
+
+ ClassCastException ex = new ClassCastException(msg);
+ throw ex;
}
// Ignore exception, continue. Presumably the classloader was the
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org