Author: kkolinko Date: Mon Nov 14 00:10:55 2011 New Revision: 1201556 URL: http://svn.apache.org/viewvc?rev=1201556&view=rev Log: Improve processing of errors that are wrapped into InvocationTargetException. Rethrow errors that must be rethrown.
Modified: tomcat/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java tomcat/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java Modified: tomcat/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java?rev=1201556&r1=1201555&r2=1201556&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java (original) +++ tomcat/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java Mon Nov 14 00:10:55 2011 @@ -40,6 +40,7 @@ import javax.servlet.jsp.tagext.BodyCont import org.apache.jasper.Constants; import org.apache.jasper.JasperException; import org.apache.jasper.compiler.Localizer; +import org.apache.jasper.util.ExceptionUtils; /** * Bunch of util methods that are used by code generated for useBean, @@ -354,6 +355,8 @@ public class JspRuntimeLibrary { } } } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } if (!ignoreMethodNF && (method == null)) { @@ -526,6 +529,8 @@ public class JspRuntimeLibrary { method.invoke (bean, new Object[] {tmpval}); } } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException ("error in invoking method", ex); } } @@ -566,6 +571,8 @@ public class JspRuntimeLibrary { Method method = getReadMethod(o.getClass(), prop); value = method.invoke(o, (Object[]) null); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException (ex); } return value; @@ -610,6 +617,8 @@ public class JspRuntimeLibrary { false ) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -622,6 +631,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { value }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -634,6 +645,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Integer.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -646,6 +659,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Short.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -658,6 +673,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Long.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -670,6 +687,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Double.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -682,6 +701,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Float.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -694,6 +715,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Character.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -706,6 +729,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Byte.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } @@ -718,6 +743,8 @@ public class JspRuntimeLibrary { Method method = getWriteMethod(bean.getClass(), prop); method.invoke(bean, new Object[] { Boolean.valueOf(value) }); } catch (Exception ex) { + Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex); + ExceptionUtils.handleThrowable(thr); throw new JasperException(ex); } } Modified: tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java?rev=1201556&r1=1201555&r2=1201556&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java (original) +++ tomcat/trunk/java/org/apache/naming/factory/BeanFactory.java Mon Nov 14 00:10:55 2011 @@ -236,6 +236,13 @@ public class BeanFactory ne.setRootCause(ie2); throw ne; } catch (java.lang.reflect.InvocationTargetException ite) { + Throwable cause = ite.getCause(); + if (cause instanceof ThreadDeath) { + throw (ThreadDeath) cause; + } + if (cause instanceof VirtualMachineError) { + throw (VirtualMachineError) cause; + } NamingException ne = new NamingException(ite.getMessage()); ne.setRootCause(ite); throw ne; Modified: tomcat/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java?rev=1201556&r1=1201555&r2=1201556&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java (original) +++ tomcat/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java Mon Nov 14 00:10:55 2011 @@ -114,9 +114,9 @@ public class DataSourceLinkFactory exten try { return method.invoke(ds,args); }catch (Throwable t) { - if (t instanceof InvocationTargetException) { - InvocationTargetException it = (InvocationTargetException)t; - throw it.getCause()!=null?it.getCause():it; + if (t instanceof InvocationTargetException + && t.getCause() != null) { + throw t.getCause(); } else { throw t; } Modified: tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java?rev=1201556&r1=1201555&r2=1201556&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java (original) +++ tomcat/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java Mon Nov 14 00:10:55 2011 @@ -16,6 +16,7 @@ */ package org.apache.naming.factory.webservices; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.net.URL; @@ -207,6 +208,15 @@ public class ServiceRefFactory portComponentRef.put(endpoint, new QName(port.getName())); } } catch (Exception e) { + if (e instanceof InvocationTargetException) { + Throwable cause = e.getCause(); + if (cause instanceof ThreadDeath) { + throw (ThreadDeath) cause; + } + if (cause instanceof VirtualMachineError) { + throw (VirtualMachineError) cause; + } + } NamingException ex = new NamingException ("Error while reading Wsdl File"); ex.initCause(e); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org