This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push:
new eb2db58 Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=63246
eb2db58 is described below
commit eb2db582dd7cc0e1d3deb271bc19c6236db8a6ba
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 7a86572..4621644 100644
--- a/java/org/apache/catalina/core/AsyncContextImpl.java
+++ b/java/org/apache/catalina/core/AsyncContextImpl.java
@@ -176,7 +176,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 ");
@@ -193,7 +193,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"));
@@ -202,11 +202,16 @@ 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;
this.dispatch = new AsyncRunnable(
request, applicationDispatcher, servletRequest,
servletResponse);
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 e89dbe3..cc21008 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -88,6 +88,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]