From: markt Date: Mon, 11 Jul 2011 13:05:30 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51494 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0e7808edfbf921c28ac82804469443e441635665;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=51494 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 --- diff --git a/java/org/apache/catalina/core/StandardContextValve.java b/java/org/apache/catalina/core/StandardContextValve.java index 934bad05a..bdaa792ab 100644 --- a/java/org/apache/catalina/core/StandardContextValve.java +++ b/java/org/apache/catalina/core/StandardContextValve.java @@ -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); + } } } } diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 9e9a9769d..14c653f64 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -62,6 +62,11 @@ Fix regression in year number formatting for AccessLogValve. (rjung) + + 51494: Prevent an NPE when a long running request completes + if the associated web application was destroyed while the request was + processing. (markt) +