Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51494
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 11 Jul 2011 13:05:30 +0000 (13:05 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 11 Jul 2011 13:05:30 +0000 (13:05 +0000)
Prevent an NPE when a long running request completes if the associated web application was destroyed while the request was processing

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

java/org/apache/catalina/core/StandardContextValve.java
webapps/docs/changelog.xml

index 934bad0..bdaa792 100644 (file)
@@ -180,7 +180,12 @@ final class StandardContextValve
             // place
             if (!(request.isAsync() || (asyncAtStart && request.getAttribute(
                         RequestDispatcher.ERROR_EXCEPTION) != null))) {
-                context.fireRequestDestroyEvent(request);
+                // Protect against NPEs if context was destroyed during a long
+                // running request.
+                StandardContext c = context;
+                if (c != null && c.getState().isAvailable()) {
+                    context.fireRequestDestroyEvent(request);
+                }
             }
         }
     }
index 9e9a976..14c653f 100644 (file)
       <fix>
         Fix regression in year number formatting for AccessLogValve. (rjung)
       </fix>
+      <fix>
+        <bug>51494</bug>: Prevent an NPE when a long running request completes
+        if the associated web application was destroyed while the request was
+        processing. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">