Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=48644
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 24 Apr 2010 19:26:17 +0000 (19:26 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 24 Apr 2010 19:26:17 +0000 (19:26 +0000)
Don't silently swallow Throwables that need to be re-thrown
Patch provided by Charlotte H (with a few tweaks)
Patch developed during the London GDC OS Jumpstart 2010

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@937680 13f79535-47bb-0310-9956-ffa450edef68

27 files changed:
java/org/apache/catalina/ant/AbstractCatalinaTask.java
java/org/apache/catalina/core/AprLifecycleListener.java
java/org/apache/catalina/core/StandardPipeline.java
java/org/apache/catalina/core/StandardWrapper.java
java/org/apache/catalina/ha/session/DeltaManager.java
java/org/apache/catalina/manager/ManagerServlet.java
java/org/apache/catalina/manager/StatusTransformer.java
java/org/apache/catalina/manager/host/HostManagerServlet.java
java/org/apache/catalina/mbeans/MBeanUtils.java
java/org/apache/catalina/realm/JDBCRealm.java
java/org/apache/catalina/session/JDBCStore.java
java/org/apache/catalina/session/ManagerBase.java
java/org/apache/catalina/session/StandardManager.java
java/org/apache/catalina/ssi/ResponseIncludeWrapper.java
java/org/apache/catalina/startup/CatalinaProperties.java
java/org/apache/catalina/startup/ContextConfig.java
java/org/apache/catalina/startup/ExpandWar.java
java/org/apache/catalina/startup/HostConfig.java
java/org/apache/catalina/startup/TldConfig.java
java/org/apache/catalina/users/MemoryUserDatabase.java
java/org/apache/catalina/util/ExtensionValidator.java
java/org/apache/catalina/valves/ErrorReportValve.java
java/org/apache/catalina/valves/JDBCAccessLogValve.java
java/org/apache/jasper/compiler/TldLocationsCache.java
java/org/apache/jasper/servlet/JspCServletContext.java
java/org/apache/jasper/util/ExceptionUtils.java [new file with mode: 0644]
java/org/apache/tomcat/util/ExceptionUtils.java [new file with mode: 0644]

index d4c8998..1a37449 100644 (file)
@@ -26,6 +26,7 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.net.URLConnection;
 import org.apache.catalina.util.Base64;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 
@@ -272,7 +273,7 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
                 try {
                     reader.close();
                 } catch (Throwable u) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(u);
                 }
                 reader = null;
             }
@@ -280,7 +281,7 @@ public abstract class AbstractCatalinaTask extends BaseRedirectorHelperTask {
                 try {
                     istream.close();
                 } catch (Throwable u) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(u);
                 }
                 istream = null;
             }
index 666317a..be188e1 100644 (file)
@@ -24,6 +24,7 @@ import java.lang.reflect.Method;
 import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -162,7 +163,7 @@ public class AprLifecycleListener
                 // is below required.                
                 terminateAPR();
             } catch (Throwable t) {
-                // Ignore
+                ExceptionUtils.handleThrowable(t);
             }
             return;
         }
index bfe7112..6fc3d47 100644 (file)
@@ -34,6 +34,7 @@ import org.apache.catalina.util.LifecycleBase;
 import org.apache.catalina.valves.ValveBase;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.modeler.Registry;
 
 
@@ -315,7 +316,7 @@ public class StandardPipeline extends LifecycleBase
                 try {
                     ((Contained) oldBasic).setContainer(null);
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
             }
         }
index 3412fc5..95c2397 100644 (file)
@@ -60,6 +60,7 @@ import org.apache.catalina.util.InstanceSupport;
 import org.apache.catalina.util.LifecycleBase;
 import org.apache.tomcat.InstanceManager;
 import org.apache.tomcat.PeriodicEventListener;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.log.SystemLogHandler;
 import org.apache.tomcat.util.modeler.Registry;
 
@@ -585,7 +586,7 @@ public class StandardWrapper
         try {
             loadServlet();
         } catch (Throwable t) {
-            // Ignore
+            ExceptionUtils.handleThrowable(t);
         }
         return (singleThreadModel);
 
index f1546b6..c440fd2 100644 (file)
@@ -43,6 +43,7 @@ import org.apache.catalina.ha.tcp.ReplicationValve;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.catalina.util.LifecycleBase;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.catalina.ha.ClusterManager;
 
@@ -978,8 +979,8 @@ public class DeltaManager extends ClusterManagerBase{
                 continue;
             try {
                 session.expire(true, isExpireSessionsOnShutdown());
-            } catch (Throwable ignore) {
-                // Ignore
+            } catch (Throwable t) {
+                ExceptionUtils.handleThrowable(t);
             } 
         }
 
index 66bb647..19905ab 100644 (file)
@@ -56,6 +56,7 @@ import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.core.StandardServer;
 import org.apache.catalina.util.RequestUtil;
 import org.apache.catalina.util.ServerInfo;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.util.modeler.Registry;
 
@@ -442,7 +443,7 @@ public class ManagerServlet
             value = getServletConfig().getInitParameter("debug");
             debug = Integer.parseInt(value);
         } catch (Throwable t) {
-            // Ignore
+            ExceptionUtils.handleThrowable(t);
         }
 
         // Acquire global JNDI resources if available
@@ -1348,7 +1349,7 @@ public class ManagerServlet
                     // Try to stop the context first to be nicer
                     context.stop();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
                 try {
                     if (path.lastIndexOf('/') > 0) {
@@ -1560,7 +1561,7 @@ public class ManagerServlet
                 try {
                     ostream.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
                 ostream = null;
             }
@@ -1568,7 +1569,7 @@ public class ManagerServlet
                 try {
                     istream.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
                 istream = null;
             }
index 2657ee3..17069c9 100644 (file)
@@ -33,6 +33,7 @@ import javax.management.ObjectName;
 import javax.servlet.http.HttpServletResponse;
 
 import org.apache.catalina.util.RequestUtil;
+import org.apache.tomcat.util.ExceptionUtils;
 
 /**
  * This is a refactoring of the servlet to externalize
@@ -158,7 +159,7 @@ public class StatusTransformer {
             method.invoke(null, paramValues);
             ok = true;
         } catch (Throwable t) {
-            // Ignore
+            ExceptionUtils.handleThrowable(t);
         }
         
         if (ok) {
index 65dfa27..e3167a0 100644 (file)
@@ -42,6 +42,7 @@ import org.apache.catalina.Host;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.startup.HostConfig;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.util.modeler.Registry;
 import org.apache.catalina.core.ContainerBase;
@@ -316,7 +317,7 @@ public class HostManagerServlet
             value = getServletConfig().getInitParameter("debug");
             debug = Integer.parseInt(value);
         } catch (Throwable t) {
-            // Ignore
+            ExceptionUtils.handleThrowable(t);
         }
 
     }
index 330d512..a315a87 100644 (file)
@@ -54,6 +54,7 @@ import org.apache.coyote.ajp.AjpProtocol;
 import org.apache.coyote.http11.Http11AprProtocol;
 import org.apache.coyote.http11.Http11NioProtocol;
 import org.apache.coyote.http11.Http11Protocol;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.IntrospectionUtils;
 import org.apache.tomcat.util.modeler.ManagedBean;
 import org.apache.tomcat.util.modeler.Registry;
@@ -1617,7 +1618,7 @@ public class MBeanUtils {
         try {
             ((Contained)valve).setContainer(null);
         } catch (Throwable t) {
-            // Ignore
+            ExceptionUtils.handleThrowable(t);
         }
         if( mserver.isRegistered(oname) ) {
             mserver.unregisterMBean(oname);
index cda6a18..f517639 100644 (file)
@@ -30,6 +30,7 @@ import java.util.Properties;
 
 import org.apache.catalina.LifecycleException;
 import org.apache.catalina.util.LifecycleBase;
+import org.apache.tomcat.util.ExceptionUtils;
 
 
 /**
@@ -450,7 +451,7 @@ public class JDBCRealm
         try {
             preparedCredentials.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.preparedCredentials = null;
 
@@ -458,7 +459,7 @@ public class JDBCRealm
         try {
             preparedRoles.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.preparedRoles = null;
 
index 9d39254..a2f6c37 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.catalina.Loader;
 import org.apache.catalina.Session;
 import org.apache.catalina.util.CustomObjectInputStream;
 import org.apache.catalina.util.LifecycleBase;
+import org.apache.tomcat.util.ExceptionUtils;
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -901,41 +902,41 @@ public class JDBCStore extends StoreBase {
         try {
             preparedSizeSql.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.preparedSizeSql = null;
 
         try {
             preparedKeysSql.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.preparedKeysSql = null;
 
         try {
             preparedSaveSql.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.preparedSaveSql = null;
 
         try {
             preparedClearSql.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
          
                try {
             preparedRemoveSql.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.preparedRemoveSql = null;
 
         try {
             preparedLoadSql.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.preparedLoadSql = null;
 
index 6b19790..1eebb60 100644 (file)
@@ -50,6 +50,7 @@ import org.apache.catalina.Session;
 import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.util.LifecycleBase;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -402,7 +403,7 @@ public abstract class ManagerBase extends LifecycleBase
                 method.invoke(null, paramValues);
                 apr = true;
             } catch (Throwable t) {
-                // Ignore
+                ExceptionUtils.handleThrowable(t);
             }
             if (apr) {
                 setEntropy(new String(result));
index b48078e..9b974b4 100644 (file)
@@ -47,6 +47,7 @@ import org.apache.catalina.util.LifecycleBase;
 import org.apache.catalina.security.SecurityUtil;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
 /**
  * Standard implementation of the <b>Manager</b> interface that provides
  * simple session persistence across restarts of this component (such as
@@ -547,7 +548,7 @@ public class StandardManager extends ManagerBase
             try {
                 session.expire(false);
             } catch (Throwable t) {
-                // Ignore
+                ExceptionUtils.handleThrowable(t);
             } finally {
                 session.recycle();
             }
@@ -621,7 +622,7 @@ public class StandardManager extends ManagerBase
                     session.expire();
                 }
             } catch (Throwable t) {
-                // Ignore
+                ExceptionUtils.handleThrowable(t);
             } finally {
                 // Measure against memory leaking if references to the session
                 // object are kept in a shared field somewhere
index f466d49..ca3154f 100644 (file)
@@ -31,6 +31,8 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpServletResponseWrapper;
 
+import org.apache.tomcat.util.ExceptionUtils;
+
 /**
  * A HttpServletResponseWrapper, used from
  * <code>SSIServletExternalResolver</code>
@@ -228,7 +230,7 @@ public class ResponseIncludeWrapper extends HttpServletResponseWrapper {
                     lastModified = RFC1123_FORMAT.parse(value).getTime();
                 }
             } catch (Throwable ignore) {
-                // Ignore
+                ExceptionUtils.handleThrowable(ignore);
             }
         } else if (lname.equals(CONTENT_TYPE)) {
             contentType = value;
@@ -254,7 +256,7 @@ public class ResponseIncludeWrapper extends HttpServletResponseWrapper {
                     lastModified = RFC1123_FORMAT.parse(value).getTime();
                 }
             } catch (Throwable ignore) {
-                // Ignore
+                ExceptionUtils.handleThrowable(ignore);
             }
         }
         else if (lname.equals(CONTENT_TYPE))
index b93bc98..e6f6c07 100644 (file)
@@ -25,6 +25,8 @@ import java.net.URL;
 import java.util.Enumeration;
 import java.util.Properties;
 
+import org.apache.tomcat.util.ExceptionUtils;
+
 
 /**
  * Utility class to read the bootstrap Catalina configuration.
@@ -91,7 +93,7 @@ public class CatalinaProperties {
                 is = (new URL(configUrl)).openStream();
             }
         } catch (Throwable t) {
-            // Ignore
+            ExceptionUtils.handleThrowable(t);
         }
 
         if (is == null) {
@@ -101,7 +103,7 @@ public class CatalinaProperties {
                 File properties = new File(conf, "catalina.properties");
                 is = new FileInputStream(properties);
             } catch (Throwable t) {
-                // Ignore
+                ExceptionUtils.handleThrowable(t);
             }
         }
 
@@ -110,7 +112,7 @@ public class CatalinaProperties {
                 is = CatalinaProperties.class.getResourceAsStream
                     ("/org/apache/catalina/startup/catalina.properties");
             } catch (Throwable t) {
-                // Ignore
+                ExceptionUtils.handleThrowable(t);
             }
         }
 
index 845edd0..4b4a18a 100644 (file)
@@ -48,6 +48,7 @@ import javax.servlet.ServletContainerInitializer;
 import javax.servlet.ServletContext;
 import javax.servlet.annotation.HandlesTypes;
 
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.bcel.classfile.AnnotationElementValue;
 import org.apache.tomcat.util.bcel.classfile.AnnotationEntry;
 import org.apache.tomcat.util.bcel.classfile.ArrayElementValue;
@@ -1730,7 +1731,7 @@ public class ContextConfig
                             try {
                                 is.close();
                             } catch (Throwable t) {
-                                // ignore
+                                ExceptionUtils.handleThrowable(t);
                             }
                         }
                     }
@@ -1743,7 +1744,7 @@ public class ContextConfig
                 try {
                     jarFile.close();
                 } catch (Throwable t) {
-                    // ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
             }
         }
@@ -1788,7 +1789,7 @@ public class ContextConfig
                             try {
                                 is.close();
                             } catch (Throwable t) {
-                                // ignore
+                                ExceptionUtils.handleThrowable(t);
                             }
                         }
                     }
@@ -1820,7 +1821,7 @@ public class ContextConfig
                     try {
                         fis.close();
                     } catch (Throwable t) {
-                        // ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                 }
             }
@@ -2087,14 +2088,14 @@ public class ContextConfig
                     try {
                         jarFile.close();
                     } catch (Throwable t) {
-                        // ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                 }
                 if (stream != null) {
                     try {
                         stream.close();
                     } catch (Throwable t) {
-                        // ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                 }
                 fragment.setURL(urlConn.getURL());
@@ -2126,7 +2127,7 @@ public class ContextConfig
                     try {
                         stream.close();
                     } catch (Throwable t) {
-                        // ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                 }
                 if (fragment == null) {
index 72d579d..51acf89 100644 (file)
@@ -32,6 +32,7 @@ import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
 
 import org.apache.catalina.Host;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -153,7 +154,7 @@ public class ExpandWar {
                 try {
                     input.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
                 input = null;
             }
@@ -161,7 +162,7 @@ public class ExpandWar {
                 try {
                     jarFile.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
                 jarFile = null;
             }
@@ -228,7 +229,7 @@ public class ExpandWar {
                 try {
                     jarFile.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
                 jarFile = null;
             }
index 5535dbe..9e8cc60 100644 (file)
@@ -49,6 +49,7 @@ import org.apache.catalina.core.StandardHost;
 import org.apache.catalina.util.IOTools;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.util.digester.Digester;
 import org.apache.tomcat.util.modeler.Registry;
@@ -872,7 +873,7 @@ public class HostConfig
                     try {
                         ostream.close();
                     } catch (Throwable t) {
-                        // Ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                     ostream = null;
                 }
@@ -880,7 +881,7 @@ public class HostConfig
                     try {
                         istream.close();
                     } catch (Throwable t) {
-                        // Ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                     istream = null;
                 }
@@ -890,7 +891,7 @@ public class HostConfig
                     try {
                         jar.close();
                     } catch (Throwable t) {
-                        // Ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                     jar = null;
                 }
@@ -942,7 +943,7 @@ public class HostConfig
                             try {
                                 istream.close();
                             } catch (Throwable t) {
-                                // Ignore
+                                ExceptionUtils.handleThrowable(t);
                             }
                             istream = null;
                         }
@@ -952,7 +953,7 @@ public class HostConfig
                             try {
                                 jar.close();
                             } catch (Throwable t) {
-                                // Ignore
+                                ExceptionUtils.handleThrowable(t);
                             }
                             jar = null;
                         }
index 5c5353e..92b0b13 100644 (file)
@@ -45,6 +45,7 @@ import org.apache.catalina.core.StandardContext;
 import org.apache.catalina.core.StandardHost;
 import org.apache.tomcat.JarScanner;
 import org.apache.tomcat.JarScannerCallback;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.tomcat.util.digester.Digester;
 import org.xml.sax.InputSource;
@@ -518,7 +519,7 @@ public final class TldConfig  implements LifecycleListener {
                 try {
                     jarFile.close();
                 } catch (Throwable t) {
-                    // ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
             }
         }
index 080b0af..201d204 100644 (file)
@@ -31,6 +31,7 @@ import org.apache.catalina.Group;
 import org.apache.catalina.Role;
 import org.apache.catalina.User;
 import org.apache.catalina.UserDatabase;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
@@ -412,7 +413,7 @@ public class MemoryUserDatabase implements UserDatabase {
                     try {
                         fis.close();
                     } catch (Throwable t) {
-                        // Ignore
+                        ExceptionUtils.handleThrowable(t);
                     }
                     throw e;
                 }
index 6c4462e..b26116f 100644 (file)
@@ -35,6 +35,7 @@ import javax.naming.directory.DirContext;
 
 import org.apache.catalina.Context;
 import org.apache.naming.resources.Resource;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 
@@ -168,7 +169,7 @@ public final class ExtensionValidator {
                 try {
                     inputStream.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
             }
         }
@@ -207,7 +208,7 @@ public final class ExtensionValidator {
                 try {
                     inputStream.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
             }
         }
@@ -398,7 +399,7 @@ public final class ExtensionValidator {
                 try {
                     jin.close();
                 } catch (Throwable t) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
             }
         }
index e381ce6..18d3aae 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.RequestUtil;
 import org.apache.catalina.util.ServerInfo;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -139,7 +140,7 @@ public class ErrorReportValve extends ValveBase {
         try {
             report(request, response, throwable);
         } catch (Throwable tt) {
-            // Ignore
+            ExceptionUtils.handleThrowable(tt);
         }
 
     }
@@ -176,7 +177,7 @@ public class ErrorReportValve extends ValveBase {
         try {
             report = sm.getString("http." + statusCode, message);
         } catch (Throwable t) {
-            // Ignore
+            ExceptionUtils.handleThrowable(t);
         }
         if (report == null)
             return;
index 8d085d3..74dcf97 100644 (file)
@@ -34,6 +34,7 @@ import org.apache.catalina.LifecycleState;
 import org.apache.catalina.connector.Request;
 import org.apache.catalina.connector.Response;
 import org.apache.catalina.util.LifecycleBase;
+import org.apache.tomcat.util.ExceptionUtils;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -575,7 +576,7 @@ public final class JDBCAccessLogValve extends ValveBase {
         try {
             ps.close();
         } catch (Throwable f) {
-            // Ignore
+            ExceptionUtils.handleThrowable(f);
         }
         this.ps = null;
 
index 787249b..794d5a2 100644 (file)
@@ -34,6 +34,7 @@ import java.util.jar.JarFile;
 import javax.servlet.ServletContext;
 
 import org.apache.jasper.JasperException;
+import org.apache.jasper.util.ExceptionUtils;
 import org.apache.jasper.xmlparser.ParserUtils;
 import org.apache.jasper.xmlparser.TreeNode;
 import org.apache.tomcat.JarScanner;
@@ -388,7 +389,7 @@ public class TldLocationsCache {
                 try {
                     jarFile.close();
                 } catch (Throwable t) {
-                    // ignore
+                    ExceptionUtils.handleThrowable(t);
                 }
             }
         }
index b902f6b..1e9c77c 100644 (file)
@@ -44,6 +44,8 @@ import javax.servlet.SessionTrackingMode;
 import javax.servlet.FilterRegistration.Dynamic;
 import javax.servlet.descriptor.JspConfigDescriptor;
 
+import org.apache.jasper.util.ExceptionUtils;
+
 
 /**
  * Simple <code>ServletContext</code> implementation without
@@ -267,7 +269,7 @@ public class JspCServletContext implements ServletContext {
                 try {
                     is.close();
                 } catch (Throwable t2) {
-                    // Ignore
+                    ExceptionUtils.handleThrowable(t2);
                 }
             }
         }
diff --git a/java/org/apache/jasper/util/ExceptionUtils.java b/java/org/apache/jasper/util/ExceptionUtils.java
new file mode 100644 (file)
index 0000000..be5eeb8
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper.util;
+
+/**
+ * Utilities for handling Throwables and Exceptions.
+ */
+public class ExceptionUtils {
+    
+    /**
+     * Checks whether the supplied Throwable is one that needs to be 
+     * rethrown and swallows all others.
+     * @param t the Throwable to check
+     */
+    public static void handleThrowable(Throwable t) {
+        if (t instanceof ThreadDeath) {
+            throw (ThreadDeath) t;
+        }
+        if (t instanceof VirtualMachineError) {
+            throw (VirtualMachineError) t;
+        }
+        // All other instances of Throwable will be silently swallowed
+    }
+}
diff --git a/java/org/apache/tomcat/util/ExceptionUtils.java b/java/org/apache/tomcat/util/ExceptionUtils.java
new file mode 100644 (file)
index 0000000..7546141
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.util;
+
+/**
+ * Utilities for handling Throwables and Exceptions.
+ */
+public class ExceptionUtils {
+    
+    /**
+     * Checks whether the supplied Throwable is one that needs to be 
+     * rethrown and swallows all others.
+     * @param t the Throwable to check
+     */
+    public static void handleThrowable(Throwable t) {
+        if (t instanceof ThreadDeath) {
+            throw (ThreadDeath) t;
+        }
+        if (t instanceof VirtualMachineError) {
+            throw (VirtualMachineError) t;
+        }
+        // All other instances of Throwable will be silently swallowed
+    }
+}