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 2014/08/06 21:14:27 UTC

svn commit: r1616310 - /tomcat/trunk/java/org/apache/catalina/core/StandardHostValve.java

Author: markt
Date: Wed Aug  6 19:14:27 2014
New Revision: 1616310

URL: http://svn.apache.org/r1616310
Log:
Refactor - no functional change

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=1616310&r1=1616309&r2=1616310&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:14:27 2014
@@ -130,54 +130,56 @@ final class StandardHostValve extends Va
         try {
             context.bind(Globals.IS_SECURITY_ENABLED, MY_CLASSLOADER);
 
-            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);
-                    }
+            if (!asyncAtStart && !context.fireRequestInitEvent(request)) {
+                // If a listener fails then request processing stops here.
+                return;
+            }
+
+            // 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);
                 }
             }
-
+        } finally {
             // 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);
         }
     }



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