tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1616309 - /tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java
Date Wed, 06 Aug 2014 19:08:07 GMT
Author: markt
Date: Wed Aug  6 19:08:07 2014
New Revision: 1616309

URL: http://svn.apache.org/r1616309
Log:
Ensure unbind() is always called after calling bind()

Modified:
    tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java

Modified: tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java?rev=1616309&r1=1616308&r2=1616309&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java (original)
+++ tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java Wed Aug  6 19:08:07
2014
@@ -127,57 +127,59 @@ final class StandardHostValve extends Va
         // ensure an infinite error handling loop is not entered
         boolean errorAtStart = response.isError();
 
-        context.bind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER);
+        try {
+            context.bind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER);
 
-        if (asyncAtStart || context.fireRequestInitEvent(request)) {
+            if (asyncAtStart || context.fireRequestInitEvent(request)) {
 
-            // Ask this Context to process this request
-            try {
-                context.getPipeline().getFirst().invoke(request, response);
-            } catch (Throwable t) {
-                ExceptionUtils.handleThrowable(t);
-                if (errorAtStart) {
-                    container.getLogger().error("Exception Processing " +
-                            request.getRequestURI(), t);
-                } else {
-                    request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
-                    throwable(request, response, t);
+                // Ask this Context to process this request
+                try {
+                    context.getPipeline().getFirst().invoke(request, response);
+                } catch (Throwable t) {
+                    ExceptionUtils.handleThrowable(t);
+                    if (errorAtStart) {
+                        container.getLogger().error("Exception Processing " +
+                                request.getRequestURI(), t);
+                    } else {
+                        request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, t);
+                        throwable(request, response, t);
+                    }
                 }
-            }
 
-            Throwable t = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
+                Throwable t = (Throwable) request.getAttribute(RequestDispatcher.ERROR_EXCEPTION);
 
-            // If the request was async at the start and an error occurred then
-            // the async error handling will kick-in and that will fire the
-            // request destroyed event *after* the error handling has taken
-            // place
-            if (!(request.isAsync() || (asyncAtStart && t != null))) {
-                // Protect against NPEs if context was destroyed during a
-                // long running request.
-                if (context.getState().isAvailable()) {
-                    if (!errorAtStart) {
-                        // Error page processing
-                        response.setSuspended(false);
-
-                        if (t != null) {
-                            throwable(request, response, t);
-                        } else {
-                            status(request, response);
+                // If the request was async at the start and an error occurred
+                // then the async error handling will kick-in and that will fire
+                // the request destroyed event *after* the error handling has
+                // taken place.
+                if (!(request.isAsync() || (asyncAtStart && t != null))) {
+                    // Protect against NPEs if context was destroyed during a
+                    // long running request.
+                    if (context.getState().isAvailable()) {
+                        if (!errorAtStart) {
+                            // Error page processing
+                            response.setSuspended(false);
+
+                            if (t != null) {
+                                throwable(request, response, t);
+                            } else {
+                                status(request, response);
+                            }
                         }
-                    }
 
-                    context.fireRequestDestroyEvent(request);
+                        context.fireRequestDestroyEvent(request);
+                    }
                 }
             }
-        }
 
-        // Access a session (if present) to update last accessed time, based on a
-        // strict interpretation of the specification
-        if (ACCESS_SESSION) {
-            request.getSession(false);
+            // Access a session (if present) to update last accessed time, based
+            // on a strict interpretation of the specification
+            if (ACCESS_SESSION) {
+                request.getSession(false);
+            }
+        } finally {
+            context.unbind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER);
         }
-
-        context.unbind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER);
     }
 
 



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


Mime
View raw message