Author: kkolinko Date: Sun Nov 13 22:59:35 2011 New Revision: 1201542 URL: http://svn.apache.org/viewvc?rev=1201542&view=rev Log: Improve processing of errors that are wrapped into InvocationTargetException. Rethrow errors that must be rethrown. Add helper methods to ExceptionUtils classes.
Modified: tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java tomcat/trunk/java/org/apache/jasper/util/ExceptionUtils.java tomcat/trunk/java/org/apache/tomcat/util/ExceptionUtils.java Modified: tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java?rev=1201542&r1=1201541&r2=1201542&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java (original) +++ tomcat/trunk/java/org/apache/catalina/core/AprLifecycleListener.java Sun Nov 13 22:59:35 2011 @@ -108,6 +108,7 @@ public class AprLifecycleListener try { initializeSSL(); } catch (Throwable t) { + t = ExceptionUtils.unwrapInvocationTargetException(t); ExceptionUtils.handleThrowable(t); log.error(sm.getString("aprListener.sslInit"), t); } @@ -129,6 +130,7 @@ public class AprLifecycleListener try { terminateAPR(); } catch (Throwable t) { + t = ExceptionUtils.unwrapInvocationTargetException(t); ExceptionUtils.handleThrowable(t); log.info(sm.getString("aprListener.aprDestroy")); } @@ -180,6 +182,7 @@ public class AprLifecycleListener patch = clazz.getField("TCN_PATCH_VERSION").getInt(null); apver = major * 1000 + minor * 100 + patch; } catch (Throwable t) { + t = ExceptionUtils.unwrapInvocationTargetException(t); ExceptionUtils.handleThrowable(t); log.info(sm.getString("aprListener.aprInit", System.getProperty("java.library.path"))); @@ -196,6 +199,7 @@ public class AprLifecycleListener // is below required. terminateAPR(); } catch (Throwable t) { + t = ExceptionUtils.unwrapInvocationTargetException(t); ExceptionUtils.handleThrowable(t); } return; Modified: tomcat/trunk/java/org/apache/jasper/util/ExceptionUtils.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/util/ExceptionUtils.java?rev=1201542&r1=1201541&r2=1201542&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/util/ExceptionUtils.java (original) +++ tomcat/trunk/java/org/apache/jasper/util/ExceptionUtils.java Sun Nov 13 22:59:35 2011 @@ -16,6 +16,9 @@ */ package org.apache.jasper.util; +import java.lang.reflect.InvocationTargetException; + + /** * Utilities for handling Throwables and Exceptions. */ @@ -35,4 +38,19 @@ public class ExceptionUtils { } // All other instances of Throwable will be silently swallowed } + + /** + * Checks whether the supplied Throwable is an instance of + * <code>InvocationTargetException</code> and returns the throwable that is + * wrapped by it, if there is any. + * + * @param t the Throwable to check + * @return <code>t</code> or <code>t.getCause()</code> + */ + public static Throwable unwrapInvocationTargetException(Throwable t) { + if (t instanceof InvocationTargetException && t.getCause() != null) { + return t.getCause(); + } + return t; + } } Modified: tomcat/trunk/java/org/apache/tomcat/util/ExceptionUtils.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/util/ExceptionUtils.java?rev=1201542&r1=1201541&r2=1201542&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/tomcat/util/ExceptionUtils.java (original) +++ tomcat/trunk/java/org/apache/tomcat/util/ExceptionUtils.java Sun Nov 13 22:59:35 2011 @@ -16,6 +16,9 @@ */ package org.apache.tomcat.util; +import java.lang.reflect.InvocationTargetException; + + /** * Utilities for handling Throwables and Exceptions. */ @@ -35,4 +38,19 @@ public class ExceptionUtils { } // All other instances of Throwable will be silently swallowed } + + /** + * Checks whether the supplied Throwable is an instance of + * <code>InvocationTargetException</code> and returns the throwable that is + * wrapped by it, if there is any. + * + * @param t the Throwable to check + * @return <code>t</code> or <code>t.getCause()</code> + */ + public static Throwable unwrapInvocationTargetException(Throwable t) { + if (t instanceof InvocationTargetException && t.getCause() != null) { + return t.getCause(); + } + return t; + } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org