You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by kk...@apache.org on 2011/11/14 02:38:19 UTC

svn commit: r1201570 - in /tomcat/tc7.0.x/trunk: ./ java/org/apache/el/parser/ java/org/apache/jasper/runtime/ java/org/apache/jasper/servlet/ java/org/apache/jasper/tagplugins/jstl/core/ java/org/apache/jasper/util/ java/org/apache/naming/factory/ jav...

Author: kkolinko
Date: Mon Nov 14 01:38:18 2011
New Revision: 1201570

URL: http://svn.apache.org/viewvc?rev=1201570&view=rev
Log:
Merging revisions r1201521 r1201542 r1201545 r1201546 r1201548 r1201555 r1201556 r1201568 from tomcat/trunk:
Improve processing of errors that are wrapped into InvocationTargetException.
Rethrow errors that must be rethrown.
Part 2 of 2. Updated mergeinfo and changelog.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstFunction.java
    tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstValue.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java
    tomcat/tc7.0.x/trunk/java/org/apache/jasper/util/ExceptionUtils.java
    tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/BeanFactory.java
    tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java
    tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/ExceptionUtils.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
    tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java
    tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 14 01:38:18 2011
@@ -1 +1 @@
-/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096
 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187381,1187
 753,1187755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1198696,1198707,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200056,1200089,1200106-1200107,1200263,1200316,1200320,1200398-1200399,1200445-1200446,1200555,1200627,1200696,1200725,1200937,1200941,1201069,1201087,1201180,1201235-1201237,1201508
+/tomcat/trunk:1156115,1156171,1156276,1156304,1156519,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1158426,1160347,1160592,1160611,1160619,1160626,1160639,1160652,1160720-1160721,1160772,1160774,1160776,1161303,1161310,1161322,1161339,1161486,1161540,1161549,1161584,1162082,1162149,1162169,1162721,1162769,1162836,1162932,1163630,1164419,1164438,1164469,1164480,1164567,1165234,1165247-1165248,1165253,1165273,1165282,1165309,1165331,1165338,1165347,1165360-1165361,1165367-1165368,1165602,1165608,1165677,1165693,1165721,1165723,1165728,1165730,1165738,1165746,1165765,1165777,1165918,1165921,1166077,1166150-1166151,1166290,1166366,1166620,1166686,1166693,1166752,1166757,1167368,1167394,1169447,1170647,1171692,1172233-1172234,1172236,1172269,1172278,1172282,1172556,1172610,1172664,1172689,1172711,1173020-1173021,1173082,1173088,1173090,1173096
 ,1173241,1173256,1173288,1173333,1173342,1173461,1173614,1173630,1173659,1173722,1174061,1174239,1174322,1174325,1174329-1174330,1174337-1174339,1174343,1174353,1174799,1174882,1174884,1174983,1175155,1175158,1175167,1175182,1175190,1175201,1175272,1175275,1175283,1175582,1175589-1175590,1175594,1175602,1175613,1175633,1175690,1175713,1175798,1175889,1175896,1175907,1176584,1176590,1176799,1177050,1177060,1177125,1177152,1177160,1177245,1177850,1177862,1177978,1178209,1178228,1178233,1178449,1178542,1178681,1178684,1178721,1179268,1179274,1180261,1180865,1180891,1180894,1180907,1181028,1181123,1181125,1181136,1181291,1181743,1182796,1183078,1183105,1183142,1183328,1183339-1183340,1183492-1183494,1183605,1184917,1184919,1185018,1185020,1185200,1185588,1185626,1185756,1185758,1186011,1186042-1186045,1186104,1186123,1186137,1186153,1186254,1186257,1186377-1186379,1186479-1186480,1186712,1186743,1186750,1186763,1186890-1186892,1186894,1186949,1187018,1187027-1187028,1187381,1187
 753,1187755,1187775,1187801,1187806,1187809,1187827,1188301,1188303-1188305,1188399,1188822,1188930-1188931,1189116,1189129,1189183,1189240,1189256,1189386,1189413-1189414,1189477,1189685,1189805,1189857,1189864,1189882,1190034,1190185,1190279,1190339,1190371,1190388-1190389,1190474,1190481,1194915,1195222-1195223,1195531,1195899,1195905,1195943,1195949,1195953,1195955,1195965,1195968,1196175,1196212,1196223,1196304-1196305,1196735,1196825,1196827,1197158,1197261,1197263,1197299-1197300,1197305,1197339-1197340,1197343,1197382,1197386-1197387,1197480,1197578,1198497,1198528,1198552,1198602,1198604,1198607,1198622,1198640,1198696,1198707,1199418,1199432,1199436,1199513,1199529,1199980,1199996,1200056,1200089,1200106-1200107,1200263,1200316,1200320,1200398-1200399,1200445-1200446,1200555,1200627,1200696,1200725,1200937,1200941,1201069,1201087,1201180,1201235-1201237,1201508,1201521,1201542,1201545-1201546,1201548,1201555-1201556,1201568

Modified: tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstFunction.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstFunction.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstFunction.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstFunction.java Mon Nov 14 01:38:18 2011
@@ -114,8 +114,15 @@ public final class AstFunction extends S
             throw new ELException(MessageFactory.get("error.function", this
                     .getOutputName()), iae);
         } catch (InvocationTargetException ite) {
+            Throwable cause = ite.getCause();
+            if (cause instanceof ThreadDeath) {
+                throw (ThreadDeath) cause;
+            }
+            if (cause instanceof VirtualMachineError) {
+                throw (VirtualMachineError) cause;
+            }
             throw new ELException(MessageFactory.get("error.function", this
-                    .getOutputName()), ite.getCause());
+                    .getOutputName()), cause);
         }
         return result;
     }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstValue.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstValue.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstValue.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/el/parser/AstValue.java Mon Nov 14 01:38:18 2011
@@ -265,7 +265,14 @@ public final class AstValue extends Simp
         } catch (IllegalArgumentException iae) {
             throw new ELException(iae);
         } catch (InvocationTargetException ite) {
-            throw new ELException(ite.getCause());
+            Throwable cause = ite.getCause();
+            if (cause instanceof ThreadDeath) {
+                throw (ThreadDeath) cause;
+            }
+            if (cause instanceof VirtualMachineError) {
+                throw (VirtualMachineError) cause;
+            }
+            throw new ELException(cause);
         }
         return result;
     }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/JspRuntimeLibrary.java Mon Nov 14 01:38:18 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/tc7.0.x/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java Mon Nov 14 01:38:18 2011
@@ -22,6 +22,7 @@ import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.tagext.Tag;
 
 import org.apache.jasper.Constants;
+import org.apache.jasper.util.ExceptionUtils;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.InstanceManager;
@@ -121,7 +122,9 @@ public class TagHandlerPool {
                 return instance;
             }
         } catch (Exception e) {
-            throw new JspException(e.getMessage(), e);
+            Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+            ExceptionUtils.handleThrowable(t);
+            throw new JspException(e.getMessage(), t);
         }
     }
 
@@ -145,8 +148,10 @@ public class TagHandlerPool {
         try {
             instanceManager.destroyInstance(handler);
         } catch (Exception e) {
+            Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+            ExceptionUtils.handleThrowable(t);
             log.warn("Error processing preDestroy on tag instance of " +
-                    handler.getClass().getName(), e);
+                    handler.getClass().getName(), t);
         }
     }
 
@@ -156,12 +161,15 @@ public class TagHandlerPool {
      */
     public synchronized void release() {
         for (int i = current; i >= 0; i--) {
-            handlers[i].release();
+            Tag handler = handlers[i];
+            handler.release();
             try {
-                instanceManager.destroyInstance(handlers[i]);
+                instanceManager.destroyInstance(handler);
             } catch (Exception e) {
-                log.warn("Error processing preDestroy on tag instance of " +
-                        handlers[i].getClass().getName(), e);
+                Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+                ExceptionUtils.handleThrowable(t);
+                log.warn("Error processing preDestroy on tag instance of "
+                        + handler.getClass().getName(), t);
             }
         }
     }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/servlet/JspServletWrapper.java Mon Nov 14 01:38:18 2011
@@ -170,12 +170,11 @@ public class JspServletWrapper {
                     try {
                         InstanceManager instanceManager = InstanceManagerFactory.getInstanceManager(config);
                         servlet = (Servlet) instanceManager.newInstance(ctxt.getFQCN(), ctxt.getJspLoader());
-                    } catch (IllegalAccessException e) {
-                        throw new JasperException(e);
-                    } catch (InstantiationException e) {
-                        throw new JasperException(e);
                     } catch (Exception e) {
-                        throw new JasperException(e);
+                        Throwable t = ExceptionUtils
+                                .unwrapInvocationTargetException(e);
+                        ExceptionUtils.handleThrowable(t);
+                        throw new JasperException(t);
                     }
                     
                     servlet.init(config);
@@ -481,9 +480,11 @@ public class JspServletWrapper {
             try {
                 instanceManager.destroyInstance(theServlet);
             } catch (Exception e) {
+                Throwable t = ExceptionUtils.unwrapInvocationTargetException(e);
+                ExceptionUtils.handleThrowable(t);
                 // Log any exception, since it can't be passed along
                 log.error(Localizer.getMessage("jsp.error.file.not.found",
-                        e.getMessage()), e);
+                        e.getMessage()), t);
             }
         }
     }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/tagplugins/jstl/core/Set.java Mon Nov 14 01:38:18 2011
@@ -156,6 +156,12 @@ public class Set implements TagPlugin {
             ctxt.generateJavaSource("        } catch (java.beans.IntrospectionException ex) {");
             ctxt.generateJavaSource("            throw new JspException(ex);");
             ctxt.generateJavaSource("        } catch (java.lang.reflect.InvocationTargetException ex) {");
+            ctxt.generateJavaSource("            if (ex.getCause() instanceof ThreadDeath) {");
+            ctxt.generateJavaSource("                throw (ThreadDeath) ex.getCause();");
+            ctxt.generateJavaSource("            }");
+            ctxt.generateJavaSource("            if (ex.getCause() instanceof VirtualMachineError) {");
+            ctxt.generateJavaSource("                throw (VirtualMachineError) ex.getCause();");
+            ctxt.generateJavaSource("            }");
             ctxt.generateJavaSource("            throw new JspException(ex);");
             ctxt.generateJavaSource("        }");
             ctxt.generateJavaSource("    }");

Modified: tomcat/tc7.0.x/trunk/java/org/apache/jasper/util/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/jasper/util/ExceptionUtils.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/jasper/util/ExceptionUtils.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/jasper/util/ExceptionUtils.java Mon Nov 14 01:38:18 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/tc7.0.x/trunk/java/org/apache/naming/factory/BeanFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/BeanFactory.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/BeanFactory.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/BeanFactory.java Mon Nov 14 01:38:18 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/tc7.0.x/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/DataSourceLinkFactory.java Mon Nov 14 01:38:18 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/tc7.0.x/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/naming/factory/webservices/ServiceRefFactory.java Mon Nov 14 01:38:18 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);

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/ExceptionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/ExceptionUtils.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/ExceptionUtils.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/ExceptionUtils.java Mon Nov 14 01:38:18 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;
+    }
 }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/IntrospectionUtils.java Mon Nov 14 01:38:18 2011
@@ -402,6 +402,7 @@ public final class IntrospectionUtils {
                 log.debug("IntrospectionUtils: IllegalAccessException for " +
                         o.getClass() + " " + name + "=" + value + ")", iae);
         } catch (InvocationTargetException ie) {
+            ExceptionUtils.handleThrowable(ie.getCause());
             if (log.isDebugEnabled())
                 log.debug("IntrospectionUtils: InvocationTargetException for " +
                         o.getClass() + " " + name + "=" + value + ")", ie);
@@ -450,6 +451,7 @@ public final class IntrospectionUtils {
                 log.debug("IntrospectionUtils: IllegalAccessException for " +
                         o.getClass() + " " + name + ")", iae);
         } catch (InvocationTargetException ie) {
+            ExceptionUtils.handleThrowable(ie.getCause());
             if (log.isDebugEnabled())
                 log.debug("IntrospectionUtils: InvocationTargetException for " +
                         o.getClass() + " " + name + ")");
@@ -845,7 +847,12 @@ public final class IntrospectionUtils {
         if (m == null)
             throw new NoSuchMethodException(target.getClass().getName() + " "
                     + methodN);
-        return m.invoke(target, new Object[] { param1 });
+        try {
+            return m.invoke(target, new Object[] { param1 });
+        } catch (InvocationTargetException ie) {
+            ExceptionUtils.handleThrowable(ie.getCause());
+            throw ie;
+        }
     }
 
     /**
@@ -869,7 +876,12 @@ public final class IntrospectionUtils {
         if (m == null)
             throw new NoSuchMethodException(target.getClass().getName() + " "
                     + methodN);
-        return m.invoke(target, emptyArray);
+        try {
+            return m.invoke(target, emptyArray);
+        } catch (InvocationTargetException ie) {
+            ExceptionUtils.handleThrowable(ie.getCause());
+            throw ie;
+        }
     }
 
     /**
@@ -888,21 +900,27 @@ public final class IntrospectionUtils {
                         " in " + target + " CLASS " + target.getClass());
             return null;
         }
-        Object o = m.invoke(target, params);
+        try {
+            Object o = m.invoke(target, params);
 
-        if (log.isDebugEnabled()) {
-            // debug
-            StringBuilder sb = new StringBuilder();
-            sb.append("" + target.getClass().getName() + "." + methodN + "( ");
-            for (int i = 0; i < params.length; i++) {
-                if (i > 0)
-                    sb.append(", ");
-                sb.append(params[i]);
+            if (log.isDebugEnabled()) {
+                // debug
+                StringBuilder sb = new StringBuilder();
+                sb.append(target.getClass().getName()).append('.')
+                        .append(methodN).append("( ");
+                for (int i = 0; i < params.length; i++) {
+                    if (i > 0)
+                        sb.append(", ");
+                    sb.append(params[i]);
+                }
+                sb.append(")");
+                log.debug("IntrospectionUtils:" + sb.toString());
             }
-            sb.append(")");
-            log.debug("IntrospectionUtils:" + sb.toString());
+            return o;
+        } catch (InvocationTargetException ie) {
+            ExceptionUtils.handleThrowable(ie.getCause());
+            throw ie;
         }
-        return o;
     }
 
     public static Object convert(String object, Class<?> paramType) {

Modified: tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/tomcat/util/digester/Digester.java Mon Nov 14 01:38:18 2011
@@ -2669,8 +2669,14 @@ public class Digester extends DefaultHan
     public SAXException createSAXException(String message, Exception e) {
         if ((e != null) &&
             (e instanceof InvocationTargetException)) {
-            Throwable t = ((InvocationTargetException) e).getTargetException();
-            if ((t != null) && (t instanceof Exception)) {
+            Throwable t = e.getCause();
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            }
+            if (t instanceof VirtualMachineError) {
+                throw (VirtualMachineError) t;
+            }
+            if (t instanceof Exception) {
                 e = (Exception) t;
             }
         }
@@ -2699,8 +2705,14 @@ public class Digester extends DefaultHan
      */
     public SAXException createSAXException(Exception e) {
         if (e instanceof InvocationTargetException) {
-            Throwable t = ((InvocationTargetException) e).getTargetException();
-            if ((t != null) && (t instanceof Exception)) {
+            Throwable t = e.getCause();
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            }
+            if (t instanceof VirtualMachineError) {
+                throw (VirtualMachineError) t;
+            }
+            if (t instanceof Exception) {
                 e = (Exception) t;
             }
         }

Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java (original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java Mon Nov 14 01:38:18 2011
@@ -164,6 +164,13 @@ public final class IntrospectionUtils {
                 log.debug("IntrospectionUtils: IllegalAccessException for " +
                         o.getClass() + " " + name + "=" + value + ")", iae);
         } catch (InvocationTargetException ie) {
+            Throwable cause = ie.getCause();
+            if (cause instanceof ThreadDeath) {
+                throw (ThreadDeath) cause;
+            }
+            if (cause instanceof VirtualMachineError) {
+                throw (VirtualMachineError) cause;
+            }
             if (log.isDebugEnabled())
                 log.debug("IntrospectionUtils: InvocationTargetException for " +
                         o.getClass() + " " + name + "=" + value + ")", ie);

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1201570&r1=1201569&r2=1201570&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Mon Nov 14 01:38:18 2011
@@ -208,6 +208,11 @@
         Deprecate unused methods in <code>IntrospectionUtils</code> class.
         (kkolinko)
       </scode>
+      <fix>
+        Improve processing of errors that are wrapped in
+        <code>InvocationTargetException</code>. Rethrow fatal errors that must
+        be rethrown. (kkolinko)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org