tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1750995 - in /tomcat/trunk: java/org/apache/catalina/core/ java/org/apache/coyote/ java/org/apache/jasper/runtime/ java/org/apache/tomcat/websocket/ webapps/docs/
Date Fri, 01 Jul 2016 19:28:42 GMT
Author: markt
Date: Fri Jul  1 19:28:42 2016
New Revision: 1750995

URL: http://svn.apache.org/viewvc?rev=1750995&view=rev
Log:
Review of all calls to user code prior to calling InstanceManager.destroy()

Modified:
    tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
    tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
    tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
    tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
    tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
    tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
    tomcat/trunk/webapps/docs/changelog.xml

Modified: tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java?rev=1750995&r1=1750994&r2=1750995&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/ApplicationFilterConfig.java Fri Jul  1 19:28:42
2016
@@ -300,8 +300,7 @@ public final class ApplicationFilterConf
 
         unregisterJMX();
 
-        if (this.filter != null)
-        {
+        if (this.filter != null) {
             try {
                 if (Globals.IS_SECURITY_ENABLED) {
                     try {

Modified: tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties?rev=1750995&r1=1750994&r2=1750995&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties (original)
+++ tomcat/trunk/java/org/apache/catalina/core/LocalStrings.properties Fri Jul  1 19:28:42
2016
@@ -204,6 +204,7 @@ standardWrapper.allocate=Error allocatin
 standardWrapper.allocateException=Allocate exception for servlet {0}
 standardWrapper.deallocateException=Deallocate exception for servlet {0}
 standardWrapper.destroyException=Servlet.destroy() for servlet {0} threw exception
+standardWrapper.destroyInstance=InstanceManager.destroy() for servlet [{0}] threw exception
 standardWrapper.initException=Servlet.init() for servlet {0} threw exception
 standardWrapper.instantiate=Error instantiating servlet class {0}
 standardWrapper.isUnavailable=Servlet {0} is currently unavailable

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java?rev=1750995&r1=1750994&r2=1750995&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardWrapper.java Fri Jul  1 19:28:42 2016
@@ -1370,10 +1370,6 @@ public class StandardWrapper extends Con
                     instance.destroy();
                 }
 
-                // Annotation processing
-                if (!((Context) getParent()).getIgnoreAnnotations()) {
-                   ((StandardContext)getParent()).getInstanceManager().destroyInstance(instance);
-                }
             } catch (Throwable t) {
                 t = ExceptionUtils.unwrapInvocationTargetException(t);
                 ExceptionUtils.handleThrowable(t);
@@ -1386,6 +1382,15 @@ public class StandardWrapper extends Con
                     (sm.getString("standardWrapper.destroyException", getName()),
                      t);
             } finally {
+                // Annotation processing
+                if (!((Context) getParent()).getIgnoreAnnotations()) {
+                    try {
+                        ((Context)getParent()).getInstanceManager().destroyInstance(instance);
+                    } catch (Throwable t) {
+                        ExceptionUtils.handleThrowable(t);
+                        log.error(sm.getString("standardWrapper.destroyInstance", getName()),
t);
+                    }
+                }
                 // Write captured output
                 if (swallowOutput) {
                     String log = SystemLogHandler.stopCapture();

Modified: tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java?rev=1750995&r1=1750994&r2=1750995&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java (original)
+++ tomcat/trunk/java/org/apache/coyote/AbstractProtocol.java Fri Jul  1 19:28:42 2016
@@ -880,8 +880,13 @@ public abstract class AbstractProtocol<S
                             ClassLoader oldCL = upgradeToken.getContextBind().bind(false,
null);
                             try {
                                 httpUpgradeHandler.destroy();
-                                instanceManager.destroyInstance(httpUpgradeHandler);
                             } finally {
+                                try {
+                                    instanceManager.destroyInstance(httpUpgradeHandler);
+                                } catch (Throwable e) {
+                                    ExceptionUtils.handleThrowable(e);
+                                    getLog().error(sm.getString("abstractConnectionHandler.error"),
e);
+                                }
                                 upgradeToken.getContextBind().unbind(false, oldCL);
                             }
                         }

Modified: tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java?rev=1750995&r1=1750994&r2=1750995&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java (original)
+++ tomcat/trunk/java/org/apache/jasper/runtime/TagHandlerPool.java Fri Jul  1 19:28:42 2016
@@ -144,15 +144,7 @@ public class TagHandlerPool {
             }
         }
         // There is no need for other threads to wait for us to release
-        handler.release();
-        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(), t);
-        }
+        doRelease(handler);
     }
 
     /**
@@ -161,19 +153,30 @@ public class TagHandlerPool {
      */
     public synchronized void release() {
         for (int i = current; i >= 0; i--) {
-            Tag handler = handlers[i];
+            doRelease(handlers[i]);
+        }
+    }
+
+
+    private void doRelease(Tag handler) {
+        try {
             handler.release();
-            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(), t);
-            }
+        } catch (Throwable t) {
+            ExceptionUtils.handleThrowable(t);
+            log.warn("Error processing release on tag instance of "
+                    + handler.getClass().getName(), t);
+        }
+        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(), t);
         }
     }
 
+
     protected static String getOption(ServletConfig config, String name,
             String defaultV) {
         if (config == null)

Modified: tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java?rev=1750995&r1=1750994&r2=1750995&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java (original)
+++ tomcat/trunk/java/org/apache/tomcat/websocket/WsSession.java Fri Jul  1 19:28:42 2016
@@ -537,24 +537,36 @@ public class WsSession implements Sessio
     private void fireEndpointOnClose(CloseReason closeReason) {
 
         // Fire the onClose event
+        Throwable throwable = null;
         InstanceManager instanceManager = webSocketContainer.getInstanceManager();
+        if (instanceManager == null) {
+            instanceManager = InstanceManagerBindings.get(applicationClassLoader);
+        }
         Thread t = Thread.currentThread();
         ClassLoader cl = t.getContextClassLoader();
         t.setContextClassLoader(applicationClassLoader);
         try {
             localEndpoint.onClose(this, closeReason);
-            if (instanceManager == null) {
-                instanceManager = InstanceManagerBindings.get(applicationClassLoader);
-            }
+        } catch (Throwable t1) {
+            ExceptionUtils.handleThrowable(t1);
+            throwable = t1;
+        } finally {
             if (instanceManager != null) {
-                instanceManager.destroyInstance(localEndpoint);
+                try {
+                    instanceManager.destroyInstance(localEndpoint);
+                } catch (Throwable t2) {
+                    ExceptionUtils.handleThrowable(t2);
+                    if (throwable == null) {
+                        throwable = t2;
+                    }
+                }
             }
-        } catch (Throwable throwable) {
-            ExceptionUtils.handleThrowable(throwable);
-            localEndpoint.onError(this, throwable);
-        } finally {
             t.setContextClassLoader(cl);
         }
+
+        if (throwable != null) {
+            fireEndpointOnError(throwable);
+        }
     }
 
 

Modified: tomcat/trunk/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1750995&r1=1750994&r2=1750995&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Fri Jul  1 19:28:42 2016
@@ -84,6 +84,11 @@
         at that point and the web resources may not be correctly configured.
         (markt)
       </fix>
+      <fix>
+        Improve error handling around user code prior to calling
+        <code>InstanceManager.destroy()</code> to ensure that the method is
+        executed. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">
@@ -110,14 +115,19 @@
         secure HTTP/2 connections that meant an incorrect value was retured when
         using the default port. (markt)
       </fix>
+      <fix>
+        Improve error handling around user code prior to calling
+        <code>InstanceManager.destroy()</code> to ensure that the method is
+        executed. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">
     <changelog>
       <fix>
-        Catch and log any <code>Exception</code>s during calls to
-        <code>Servlet.destroy()</code> when destroying the Servlet associated
-        with a JSP page. (markt)
+        Improve error handling around user code prior to calling
+        <code>InstanceManager.destroy()</code> to ensure that the method is
+        executed. (markt)
       </fix>
     </changelog>
   </subsection>
@@ -129,6 +139,11 @@
         dedicated WebSocket Executor. It has been replaced by the use of the
         Connector/Endpoint provided Executor. (markt)
       </scode>
+      <fix>
+        Improve error handling around user code prior to calling
+        <code>InstanceManager.destroy()</code> to ensure that the method is
+        executed. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Web Applications">



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


Mime
View raw message