This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/7.0.x by this push:
new 4e9bb1c Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63246
4e9bb1c is described below
commit 4e9bb1c1c6907d90cbbdc415866037521b67b3ef
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Mar 8 22:01:25 2019 +0000
Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63246
Fix a potential NullPointerException when calling
AsyncContext.dispatch()
---
java/org/apache/catalina/core/AsyncContextImpl.java | 11 ++++++++---
webapps/docs/changelog.xml | 4 ++++
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/catalina/core/AsyncContextImpl.java
b/java/org/apache/catalina/core/AsyncContextImpl.java
index 489ca80..15c6610 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -210,7 +210,7 @@ public class AsyncContextImpl implements AsyncContext,
AsyncContextCallback {
}
@Override
- public void dispatch(ServletContext context, String path) {
+ public void dispatch(ServletContext servletContext, String path) {
synchronized (asyncContextLock) {
if (log.isDebugEnabled()) {
logDebug("dispatch ");
@@ -227,7 +227,7 @@ public class AsyncContextImpl implements AsyncContext,
AsyncContextCallback {
request.setAttribute(ASYNC_PATH_INFO, request.getPathInfo());
request.setAttribute(ASYNC_QUERY_STRING,
request.getQueryString());
}
- final RequestDispatcher requestDispatcher =
context.getRequestDispatcher(path);
+ final RequestDispatcher requestDispatcher =
servletContext.getRequestDispatcher(path);
if (!(requestDispatcher instanceof AsyncDispatcher)) {
throw new UnsupportedOperationException(
sm.getString("asyncContextImpl.noAsyncDispatcher"));
@@ -236,6 +236,11 @@ public class AsyncContextImpl implements AsyncContext,
AsyncContextCallback {
(AsyncDispatcher) requestDispatcher;
final ServletRequest servletRequest = getRequest();
final ServletResponse servletResponse = getResponse();
+ // https://bz.apache.org/bugzilla/show_bug.cgi?id=63246
+ // Take a local copy as the dispatch may complete the
+ // request/response and that in turn may trigger recycling of this
+ // object before the in-progress count can be decremented
+ final Context context = this.context;
Runnable run = new Runnable() {
@Override
public void run() {
@@ -252,7 +257,7 @@ public class AsyncContextImpl implements AsyncContext,
AsyncContextCallback {
this.dispatch = run;
this.request.getCoyoteRequest().action(ActionCode.ASYNC_DISPATCH,
null);
clearServletRequestResponse();
- this.context.decrementInProgressAsyncCount();
+ context.decrementInProgressAsyncCount();
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index f6d55d8..de7aeca 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -80,6 +80,10 @@
thanks to YourKit Java profiler for helping to track down the wasted
memory and the root causes. (markt)
</fix>
+ <fix>
+ <bug>63246</bug>: Fix a potential <code>NullPointerException</code>
when
+ calling <code>AsyncContext.dispatch()</code>. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Coyote">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]