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;
try {
reader.close();
} catch (Throwable u) {
- // Ignore
+ ExceptionUtils.handleThrowable(u);
}
reader = null;
}
try {
istream.close();
} catch (Throwable u) {
- // Ignore
+ ExceptionUtils.handleThrowable(u);
}
istream = null;
}
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;
// is below required.
terminateAPR();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
return;
}
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;
try {
((Contained) oldBasic).setContainer(null);
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
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;
try {
loadServlet();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
return (singleThreadModel);
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;
continue;
try {
session.expire(true, isExpireSessionsOnShutdown());
- } catch (Throwable ignore) {
- // Ignore
+ } catch (Throwable t) {
+ ExceptionUtils.handleThrowable(t);
}
}
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;
value = getServletConfig().getInitParameter("debug");
debug = Integer.parseInt(value);
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
// Acquire global JNDI resources if available
// Try to stop the context first to be nicer
context.stop();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
try {
if (path.lastIndexOf('/') > 0) {
try {
ostream.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
ostream = null;
}
try {
istream.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
istream = null;
}
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
method.invoke(null, paramValues);
ok = true;
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
if (ok) {
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;
value = getServletConfig().getInitParameter("debug");
debug = Integer.parseInt(value);
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
}
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;
try {
((Contained)valve).setContainer(null);
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
if( mserver.isRegistered(oname) ) {
mserver.unregisterMBean(oname);
import org.apache.catalina.LifecycleException;
import org.apache.catalina.util.LifecycleBase;
+import org.apache.tomcat.util.ExceptionUtils;
/**
try {
preparedCredentials.close();
} catch (Throwable f) {
- // Ignore
+ ExceptionUtils.handleThrowable(f);
}
this.preparedCredentials = null;
try {
preparedRoles.close();
} catch (Throwable f) {
- // Ignore
+ ExceptionUtils.handleThrowable(f);
}
this.preparedRoles = null;
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;
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;
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;
method.invoke(null, paramValues);
apr = true;
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
if (apr) {
setEntropy(new String(result));
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
try {
session.expire(false);
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
} finally {
session.recycle();
}
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
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
+import org.apache.tomcat.util.ExceptionUtils;
+
/**
* A HttpServletResponseWrapper, used from
* <code>SSIServletExternalResolver</code>
lastModified = RFC1123_FORMAT.parse(value).getTime();
}
} catch (Throwable ignore) {
- // Ignore
+ ExceptionUtils.handleThrowable(ignore);
}
} else if (lname.equals(CONTENT_TYPE)) {
contentType = value;
lastModified = RFC1123_FORMAT.parse(value).getTime();
}
} catch (Throwable ignore) {
- // Ignore
+ ExceptionUtils.handleThrowable(ignore);
}
}
else if (lname.equals(CONTENT_TYPE))
import java.util.Enumeration;
import java.util.Properties;
+import org.apache.tomcat.util.ExceptionUtils;
+
/**
* Utility class to read the bootstrap Catalina configuration.
is = (new URL(configUrl)).openStream();
}
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
if (is == null) {
File properties = new File(conf, "catalina.properties");
is = new FileInputStream(properties);
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
}
is = CatalinaProperties.class.getResourceAsStream
("/org/apache/catalina/startup/catalina.properties");
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
}
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;
try {
is.close();
} catch (Throwable t) {
- // ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
try {
jarFile.close();
} catch (Throwable t) {
- // ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
try {
is.close();
} catch (Throwable t) {
- // ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
try {
fis.close();
} catch (Throwable t) {
- // ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
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());
try {
stream.close();
} catch (Throwable t) {
- // ignore
+ ExceptionUtils.handleThrowable(t);
}
}
if (fragment == null) {
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;
try {
input.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
input = null;
}
try {
jarFile.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
jarFile = null;
}
try {
jarFile.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
jarFile = null;
}
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;
try {
ostream.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
ostream = null;
}
try {
istream.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
istream = null;
}
try {
jar.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
jar = null;
}
try {
istream.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
istream = null;
}
try {
jar.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
jar = null;
}
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;
try {
jarFile.close();
} catch (Throwable t) {
- // ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
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;
try {
fis.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
throw e;
}
import org.apache.catalina.Context;
import org.apache.naming.resources.Resource;
+import org.apache.tomcat.util.ExceptionUtils;
import org.apache.tomcat.util.res.StringManager;
try {
inputStream.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
try {
inputStream.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
try {
jin.close();
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
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;
/**
try {
report(request, response, throwable);
} catch (Throwable tt) {
- // Ignore
+ ExceptionUtils.handleThrowable(tt);
}
}
try {
report = sm.getString("http." + statusCode, message);
} catch (Throwable t) {
- // Ignore
+ ExceptionUtils.handleThrowable(t);
}
if (report == null)
return;
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;
/**
try {
ps.close();
} catch (Throwable f) {
- // Ignore
+ ExceptionUtils.handleThrowable(f);
}
this.ps = null;
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;
try {
jarFile.close();
} catch (Throwable t) {
- // ignore
+ ExceptionUtils.handleThrowable(t);
}
}
}
import javax.servlet.FilterRegistration.Dynamic;
import javax.servlet.descriptor.JspConfigDescriptor;
+import org.apache.jasper.util.ExceptionUtils;
+
/**
* Simple <code>ServletContext</code> implementation without
try {
is.close();
} catch (Throwable t2) {
- // Ignore
+ ExceptionUtils.handleThrowable(t2);
}
}
}
--- /dev/null
+/*
+ * 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
+ }
+}
--- /dev/null
+/*
+ * 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
+ }
+}