1
0

If an InvocationTargetException is thrown during the construction of a new

Log instance, unwrap it so that the message on the LogConfigurationException
identifies the actual cause of the problem.

PR:  Bugzilla #26598
Submitted By:  Brian Curnow <bcurnow AT gfs DOT com>


git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@139021 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Craig R. McClanahan
2004-03-06 21:25:36 +00:00
parent 8cdc7ae4e4
commit b7a766054f
2 changed files with 16 additions and 2 deletions

View File

@@ -16,7 +16,7 @@
--> -->
$Id: RELEASE-NOTES.txt,v 1.4 2004/02/28 23:20:57 craigmcc Exp $ $Id: RELEASE-NOTES.txt,v 1.5 2004/03/06 21:25:36 craigmcc Exp $
Commons Logging Package Commons Logging Package
Version 1.0.4 Version 1.0.4
@@ -69,6 +69,12 @@ BUG FIXES:
[LogFactory] Improve usability of error messages reporting [LogFactory] Improve usability of error messages reporting
configuration problems. configuration problems.
[LogFactoryImpl] If an InvocationTargetException is returned during the
creation of a new Log instance, unwrap the underlying
cause and pass it in to the LogConfigurationException
constructor. This will make the actual cause of the
problem easier to diagnose.
[JDK14Logger] Implement Serializable, remove "final" declaration for [JDK14Logger] Implement Serializable, remove "final" declaration for
easy subclassing. easy subclassing.

View File

@@ -18,6 +18,7 @@ package org.apache.commons.logging.impl;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
@@ -62,7 +63,7 @@ import org.apache.commons.logging.LogFactory;
* @author Rod Waldhoff * @author Rod Waldhoff
* @author Craig R. McClanahan * @author Craig R. McClanahan
* @author Richard A. Sitze * @author Richard A. Sitze
* @version $Revision: 1.31 $ $Date: 2004/02/28 22:16:16 $ * @version $Revision: 1.32 $ $Date: 2004/03/06 21:25:36 $
*/ */
public class LogFactoryImpl extends LogFactory { public class LogFactoryImpl extends LogFactory {
@@ -510,6 +511,13 @@ public class LogFactoryImpl extends LogFactory {
logMethod.invoke(instance, params); logMethod.invoke(instance, params);
} }
return (instance); return (instance);
} catch (InvocationTargetException e) {
Throwable c = e.getTargetException();
if (c != null) {
throw new LogConfigurationException(c);
} else {
throw new LogConfigurationException(e);
}
} catch (Throwable t) { } catch (Throwable t) {
throw new LogConfigurationException(t); throw new LogConfigurationException(t);
} }