From b7a766054f6d1da595259b0b3c4e5d090d1ec8eb Mon Sep 17 00:00:00 2001 From: "Craig R. McClanahan" Date: Sat, 6 Mar 2004 21:25:36 +0000 Subject: [PATCH] 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 git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/logging/trunk@139021 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE-NOTES.txt | 8 +++++++- .../apache/commons/logging/impl/LogFactoryImpl.java | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt index 70cefb0..2bcae1a 100644 --- a/RELEASE-NOTES.txt +++ b/RELEASE-NOTES.txt @@ -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 Version 1.0.4 @@ -69,6 +69,12 @@ BUG FIXES: [LogFactory] Improve usability of error messages reporting 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 easy subclassing. diff --git a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java index 11bb4b2..51ac8b0 100644 --- a/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java +++ b/src/java/org/apache/commons/logging/impl/LogFactoryImpl.java @@ -18,6 +18,7 @@ package org.apache.commons.logging.impl; import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.security.AccessController; import java.security.PrivilegedAction; @@ -62,7 +63,7 @@ import org.apache.commons.logging.LogFactory; * @author Rod Waldhoff * @author Craig R. McClanahan * @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 { @@ -510,6 +511,13 @@ public class LogFactoryImpl extends LogFactory { logMethod.invoke(instance, params); } return (instance); + } catch (InvocationTargetException e) { + Throwable c = e.getTargetException(); + if (c != null) { + throw new LogConfigurationException(c); + } else { + throw new LogConfigurationException(e); + } } catch (Throwable t) { throw new LogConfigurationException(t); }