You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2023/05/11 18:59:04 UTC

[tomcat] branch main updated: Remove references to ThreadDeath exception

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/main by this push:
     new 9efa28ae79 Remove references to ThreadDeath exception
9efa28ae79 is described below

commit 9efa28ae7998a7b7279421d05326707a857ce7ee
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu May 11 19:58:51 2023 +0100

    Remove references to ThreadDeath exception
    
    It is no longer thrown by the JRE and should not be thrown by any other
    component. If it is thrown, it will be treated as any other Exception as
    it won't represent the 'death' of a thread.
---
 java/jakarta/el/Util.java                                           | 3 ---
 java/org/apache/catalina/startup/Bootstrap.java                     | 3 ---
 java/org/apache/catalina/startup/CatalinaProperties.java            | 3 ---
 java/org/apache/catalina/tribes/membership/McastServiceImpl.java    | 3 ---
 java/org/apache/catalina/tribes/util/ExceptionUtils.java            | 3 ---
 java/org/apache/el/parser/AstFunction.java                          | 3 ---
 java/org/apache/el/parser/AstValue.java                             | 3 ---
 java/org/apache/el/util/ExceptionUtils.java                         | 3 ---
 java/org/apache/jasper/runtime/ExceptionUtils.java                  | 3 ---
 java/org/apache/jasper/tagplugins/jstl/core/Set.java                | 3 ---
 java/org/apache/naming/factory/BeanFactory.java                     | 3 ---
 java/org/apache/naming/factory/DataSourceLinkFactory.java           | 3 ---
 java/org/apache/naming/factory/EjbFactory.java                      | 3 ---
 java/org/apache/naming/factory/FactoryBase.java                     | 3 ---
 java/org/apache/naming/factory/ResourceFactory.java                 | 3 ---
 java/org/apache/tomcat/dbcp/pool2/PoolUtils.java                    | 5 -----
 java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java | 2 +-
 java/org/apache/tomcat/jni/Library.java                             | 4 ++--
 java/org/apache/tomcat/util/ExceptionUtils.java                     | 3 ---
 java/org/apache/tomcat/util/digester/Digester.java                  | 6 ------
 .../apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java    | 3 ---
 .../tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java | 3 ---
 test/org/apache/catalina/tribes/demos/IntrospectionUtils.java       | 3 ---
 23 files changed, 3 insertions(+), 71 deletions(-)

diff --git a/java/jakarta/el/Util.java b/java/jakarta/el/Util.java
index b1fc7046d9..168f89ce42 100644
--- a/java/jakarta/el/Util.java
+++ b/java/jakarta/el/Util.java
@@ -47,9 +47,6 @@ class Util {
      * @param t the Throwable to check
      */
     static void handleThrowable(Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof VirtualMachineError) {
             throw (VirtualMachineError) t;
         }
diff --git a/java/org/apache/catalina/startup/Bootstrap.java b/java/org/apache/catalina/startup/Bootstrap.java
index b0c52ef1c0..d5a6bdcd29 100644
--- a/java/org/apache/catalina/startup/Bootstrap.java
+++ b/java/org/apache/catalina/startup/Bootstrap.java
@@ -544,9 +544,6 @@ public final class Bootstrap {
 
     // Copied from ExceptionUtils since that class is not visible during start
     static void handleThrowable(Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof StackOverflowError) {
             // Swallow silently - it should be recoverable
             return;
diff --git a/java/org/apache/catalina/startup/CatalinaProperties.java b/java/org/apache/catalina/startup/CatalinaProperties.java
index 2bf690705b..eb144a9e77 100644
--- a/java/org/apache/catalina/startup/CatalinaProperties.java
+++ b/java/org/apache/catalina/startup/CatalinaProperties.java
@@ -133,9 +133,6 @@ public class CatalinaProperties {
 
     // Copied from ExceptionUtils since that class is not visible during start
     private static void handleThrowable(Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof VirtualMachineError) {
             throw (VirtualMachineError) t;
         }
diff --git a/java/org/apache/catalina/tribes/membership/McastServiceImpl.java b/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
index 6c6e5fe6c7..4303958ad0 100644
--- a/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
+++ b/java/org/apache/catalina/tribes/membership/McastServiceImpl.java
@@ -460,9 +460,6 @@ public class McastServiceImpl extends MembershipProviderBase {
                                 msgservice.messageReceived(datum);
                             }
                         } catch (Throwable t1) {
-                            if (t1 instanceof ThreadDeath) {
-                                throw (ThreadDeath) t1;
-                            }
                             if (t1 instanceof VirtualMachineError) {
                                 throw (VirtualMachineError) t1;
                             }
diff --git a/java/org/apache/catalina/tribes/util/ExceptionUtils.java b/java/org/apache/catalina/tribes/util/ExceptionUtils.java
index c352e3c39f..256cd21beb 100644
--- a/java/org/apache/catalina/tribes/util/ExceptionUtils.java
+++ b/java/org/apache/catalina/tribes/util/ExceptionUtils.java
@@ -27,9 +27,6 @@ public class ExceptionUtils {
      * @param t the Throwable to check
      */
     public static void handleThrowable(Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof StackOverflowError) {
             // Swallow silently - it should be recoverable
             return;
diff --git a/java/org/apache/el/parser/AstFunction.java b/java/org/apache/el/parser/AstFunction.java
index bac8db1be9..78bc01ecc7 100644
--- a/java/org/apache/el/parser/AstFunction.java
+++ b/java/org/apache/el/parser/AstFunction.java
@@ -189,9 +189,6 @@ public final class AstFunction extends SimpleNode {
             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;
             }
diff --git a/java/org/apache/el/parser/AstValue.java b/java/org/apache/el/parser/AstValue.java
index 2bd5205fdf..e244eedb43 100644
--- a/java/org/apache/el/parser/AstValue.java
+++ b/java/org/apache/el/parser/AstValue.java
@@ -255,9 +255,6 @@ public final class AstValue extends SimpleNode {
             throw new ELException(e);
         } catch (InvocationTargetException ite) {
             Throwable cause = ite.getCause();
-            if (cause instanceof ThreadDeath) {
-                throw (ThreadDeath) cause;
-            }
             if (cause instanceof VirtualMachineError) {
                 throw (VirtualMachineError) cause;
             }
diff --git a/java/org/apache/el/util/ExceptionUtils.java b/java/org/apache/el/util/ExceptionUtils.java
index d8a76ff184..7c3c054d9f 100644
--- a/java/org/apache/el/util/ExceptionUtils.java
+++ b/java/org/apache/el/util/ExceptionUtils.java
@@ -30,9 +30,6 @@ public class ExceptionUtils {
      * @param t the Throwable to check
      */
     public static void handleThrowable(Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof StackOverflowError) {
             // Swallow silently - it should be recoverable
             return;
diff --git a/java/org/apache/jasper/runtime/ExceptionUtils.java b/java/org/apache/jasper/runtime/ExceptionUtils.java
index 344bce2aa5..0a1b9a677a 100644
--- a/java/org/apache/jasper/runtime/ExceptionUtils.java
+++ b/java/org/apache/jasper/runtime/ExceptionUtils.java
@@ -30,9 +30,6 @@ public class ExceptionUtils {
      * @param t the Throwable to check
      */
     public static void handleThrowable(Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof StackOverflowError) {
             // Swallow silently - it should be recoverable
             return;
diff --git a/java/org/apache/jasper/tagplugins/jstl/core/Set.java b/java/org/apache/jasper/tagplugins/jstl/core/Set.java
index 81dbf797a3..2e664a0538 100644
--- a/java/org/apache/jasper/tagplugins/jstl/core/Set.java
+++ b/java/org/apache/jasper/tagplugins/jstl/core/Set.java
@@ -160,9 +160,6 @@ 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("            }");
diff --git a/java/org/apache/naming/factory/BeanFactory.java b/java/org/apache/naming/factory/BeanFactory.java
index 1f207cd712..6711be1ae9 100644
--- a/java/org/apache/naming/factory/BeanFactory.java
+++ b/java/org/apache/naming/factory/BeanFactory.java
@@ -215,9 +215,6 @@ public class BeanFactory implements ObjectFactory {
                 throw ne;
             } catch (java.lang.ReflectiveOperationException e) {
                 Throwable cause = e.getCause();
-                if (cause instanceof ThreadDeath) {
-                    throw (ThreadDeath) cause;
-                }
                 if (cause instanceof VirtualMachineError) {
                     throw (VirtualMachineError) cause;
                 }
diff --git a/java/org/apache/naming/factory/DataSourceLinkFactory.java b/java/org/apache/naming/factory/DataSourceLinkFactory.java
index cd19e29627..51a086eb36 100644
--- a/java/org/apache/naming/factory/DataSourceLinkFactory.java
+++ b/java/org/apache/naming/factory/DataSourceLinkFactory.java
@@ -74,9 +74,6 @@ public class DataSourceLinkFactory extends ResourceLinkFactory {
         }catch (Exception x) {
             if (x instanceof InvocationTargetException) {
                 Throwable cause = x.getCause();
-                if (cause instanceof ThreadDeath) {
-                    throw (ThreadDeath) cause;
-                }
                 if (cause instanceof VirtualMachineError) {
                     throw (VirtualMachineError) cause;
                 }
diff --git a/java/org/apache/naming/factory/EjbFactory.java b/java/org/apache/naming/factory/EjbFactory.java
index 0820e16e84..d6247e08e6 100644
--- a/java/org/apache/naming/factory/EjbFactory.java
+++ b/java/org/apache/naming/factory/EjbFactory.java
@@ -49,9 +49,6 @@ public class EjbFactory extends FactoryBase {
             if (t instanceof NamingException) {
                 throw (NamingException) t;
             }
-            if (t instanceof ThreadDeath) {
-                throw (ThreadDeath) t;
-            }
             if (t instanceof VirtualMachineError) {
                 throw (VirtualMachineError) t;
             }
diff --git a/java/org/apache/naming/factory/FactoryBase.java b/java/org/apache/naming/factory/FactoryBase.java
index a49c4b1e40..292c5daef6 100644
--- a/java/org/apache/naming/factory/FactoryBase.java
+++ b/java/org/apache/naming/factory/FactoryBase.java
@@ -77,9 +77,6 @@ public abstract class FactoryBase implements ObjectFactory {
                     if (t instanceof NamingException) {
                         throw (NamingException) t;
                     }
-                    if (t instanceof ThreadDeath) {
-                        throw (ThreadDeath) t;
-                    }
                     if (t instanceof VirtualMachineError) {
                         throw (VirtualMachineError) t;
                     }
diff --git a/java/org/apache/naming/factory/ResourceFactory.java b/java/org/apache/naming/factory/ResourceFactory.java
index 00c3b8b400..83dc595cfe 100644
--- a/java/org/apache/naming/factory/ResourceFactory.java
+++ b/java/org/apache/naming/factory/ResourceFactory.java
@@ -65,9 +65,6 @@ public class ResourceFactory extends FactoryBase {
                 if (t instanceof NamingException) {
                     throw (NamingException) t;
                 }
-                if (t instanceof ThreadDeath) {
-                    throw (ThreadDeath) t;
-                }
                 if (t instanceof VirtualMachineError) {
                     throw (VirtualMachineError) t;
                 }
diff --git a/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java b/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
index 0cce5c8e52..097a772948 100644
--- a/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
+++ b/java/org/apache/tomcat/dbcp/pool2/PoolUtils.java
@@ -1443,15 +1443,10 @@ public final class PoolUtils {
      *
      * @param t
      *            The Throwable to check
-     * @throws ThreadDeath
-     *             if that is passed in
      * @throws VirtualMachineError
      *             if that is passed in
      */
     public static void checkRethrow(final Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof VirtualMachineError) {
             throw (VirtualMachineError) t;
         }
diff --git a/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java b/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
index 7f02e77fca..96751404eb 100644
--- a/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
+++ b/java/org/apache/tomcat/dbcp/pool2/impl/SoftReferenceObjectPool.java
@@ -160,7 +160,7 @@ public class SoftReferenceObjectPool<T> extends BaseObjectPool<T> {
      * raises an exception on activation or fails validation,
      * {@code NoSuchElementException} is thrown. Exceptions thrown by
      * {@code MakeObject} are propagated to the caller; but other than
-     * {@code ThreadDeath} or {@code VirtualMachineError}, exceptions
+     * {@code VirtualMachineError}, exceptions
      * generated by activation, validation or destroy methods are swallowed
      * silently.
      * </p>
diff --git a/java/org/apache/tomcat/jni/Library.java b/java/org/apache/tomcat/jni/Library.java
index cadbcc08d1..2fa3b07ecd 100644
--- a/java/org/apache/tomcat/jni/Library.java
+++ b/java/org/apache/tomcat/jni/Library.java
@@ -38,7 +38,7 @@ public final class Library {
             try {
                 System.load(library.getAbsolutePath());
                 loaded = true;
-            } catch (ThreadDeath | VirtualMachineError t) {
+            } catch (VirtualMachineError t) {
                 throw t;
             } catch (Throwable t) {
                 if (library.exists()) {
@@ -61,7 +61,7 @@ public final class Library {
                 try {
                     System.loadLibrary(value);
                     loaded = true;
-                } catch (ThreadDeath | VirtualMachineError t) {
+                } catch (VirtualMachineError t) {
                     throw t;
                 } catch (Throwable t) {
                     String name = System.mapLibraryName(value);
diff --git a/java/org/apache/tomcat/util/ExceptionUtils.java b/java/org/apache/tomcat/util/ExceptionUtils.java
index 3df395fa5c..2d9c94d8c6 100644
--- a/java/org/apache/tomcat/util/ExceptionUtils.java
+++ b/java/org/apache/tomcat/util/ExceptionUtils.java
@@ -30,9 +30,6 @@ public class ExceptionUtils {
      * @param t the Throwable to check
      */
     public static void handleThrowable(Throwable t) {
-        if (t instanceof ThreadDeath) {
-            throw (ThreadDeath) t;
-        }
         if (t instanceof StackOverflowError) {
             // Swallow silently - it should be recoverable
             return;
diff --git a/java/org/apache/tomcat/util/digester/Digester.java b/java/org/apache/tomcat/util/digester/Digester.java
index b08b6076c1..83c576dde0 100644
--- a/java/org/apache/tomcat/util/digester/Digester.java
+++ b/java/org/apache/tomcat/util/digester/Digester.java
@@ -1935,9 +1935,6 @@ public class Digester extends DefaultHandler2 {
     public SAXException createSAXException(String message, Exception e) {
         if ((e != null) && (e instanceof InvocationTargetException)) {
             Throwable t = e.getCause();
-            if (t instanceof ThreadDeath) {
-                throw (ThreadDeath) t;
-            }
             if (t instanceof VirtualMachineError) {
                 throw (VirtualMachineError) t;
             }
@@ -1972,9 +1969,6 @@ public class Digester extends DefaultHandler2 {
     public SAXException createSAXException(Exception e) {
         if (e instanceof InvocationTargetException) {
             Throwable t = e.getCause();
-            if (t instanceof ThreadDeath) {
-                throw (ThreadDeath) t;
-            }
             if (t instanceof VirtualMachineError) {
                 throw (VirtualMachineError) t;
             }
diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
index 837fc5611a..0d02727e87 100644
--- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
+++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/naming/GenericNamingResourcesFactory.java
@@ -213,9 +213,6 @@ public class GenericNamingResourcesFactory implements ObjectFactory {
             }
         } catch (InvocationTargetException ie) {
             Throwable cause = ie.getCause();
-            if (cause instanceof ThreadDeath) {
-                throw (ThreadDeath) cause;
-            }
             if (cause instanceof VirtualMachineError) {
                 throw (VirtualMachineError) cause;
             }
diff --git a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java
index e3f8de3691..59461911ec 100644
--- a/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java
+++ b/modules/jdbc-pool/src/main/java/org/apache/tomcat/jdbc/pool/interceptor/StatementDecoratorInterceptor.java
@@ -99,9 +99,6 @@ public class StatementDecoratorInterceptor extends AbstractCreateStatementInterc
         } catch (Exception x) {
             if (x instanceof InvocationTargetException) {
                 Throwable cause = x.getCause();
-                if (cause instanceof ThreadDeath) {
-                    throw (ThreadDeath) cause;
-                }
                 if (cause instanceof VirtualMachineError) {
                     throw (VirtualMachineError) cause;
                 }
diff --git a/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java b/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
index 56cc59ec81..244926bc71 100644
--- a/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
+++ b/test/org/apache/catalina/tribes/demos/IntrospectionUtils.java
@@ -164,9 +164,6 @@ public final class IntrospectionUtils {
             }
         } catch (InvocationTargetException ie) {
             Throwable cause = ie.getCause();
-            if (cause instanceof ThreadDeath) {
-                throw (ThreadDeath) cause;
-            }
             if (cause instanceof VirtualMachineError) {
                 throw (VirtualMachineError) cause;
             }


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