Fix NPE in CoyoteAdapter when postParseRequest() call fails.
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 4 Feb 2011 03:07:37 +0000 (03:07 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Fri, 4 Feb 2011 03:07:37 +0000 (03:07 +0000)
That was caused by mappingData.context being null.
This NPE occurence in 7.0.7 was reported on the users list.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1067072 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/connector/CoyoteAdapter.java
webapps/docs/changelog.xml

index 59f8c45..153788f 100644 (file)
@@ -375,7 +375,8 @@ public class CoyoteAdapter implements Adapter {
             // Parse and set Catalina and configuration specific 
             // request parameters
             req.getRequestProcessor().setWorkerThreadName(Thread.currentThread().getName());
-            if (postParseRequest(req, request, res, response)) {
+            boolean postParseSuccess = postParseRequest(req, request, res, response);
+            if (postParseSuccess) {
                 //check valves if we support async
                 request.setAsyncSupported(connector.getService().getContainer().getPipeline().isAsyncSupported());
                 // Calling the container
@@ -406,9 +407,14 @@ public class CoyoteAdapter implements Adapter {
                 async = true;
             } else if (!comet) {
                 response.finishResponse();
-                ((Context) request.getMappingData().context).logAccess(request,
-                        response,
-                        System.currentTimeMillis() - req.getStartTime(), false);
+                if (postParseSuccess) {
+                    // Log only if processing was invoked.
+                    // If postParseRequest() failed, it has already logged it.
+                    ((Context) request.getMappingData().context).logAccess(
+                            request, response,
+                            System.currentTimeMillis() - req.getStartTime(),
+                            false);
+                }
                 req.action(ActionCode.POST_REQUEST , null);
             }
 
index 3a61fd2..c0f994d 100644 (file)
 <!--
   General, Catalina, Coyote, Jasper, Cluster, Web applications, Extras, Other
 -->
+<section name="Tomcat 7.0.8 (markt)">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        Fix NPE in CoyoteAdapter when postParseRequest() call fails. (kkolinko)
+      </fix>
+    </changelog>
+  </subsection>
+</section>
 <section name="Tomcat 7.0.7 (markt)">
   <subsection name="Catalina">
     <changelog>