371903: Implement servlet 3.0 spec change (spec section 9.4) to not commit response in Dispatcher.forward() when request.isAysncStarted()

Signed-off-by: Greg Wilkins <gregw@webtide.com>
This commit is contained in:
Thomas Becker 2012-02-17 19:09:48 +01:00 committed by Greg Wilkins
parent 7a58f3408e
commit 265d35324a
1 changed files with 29 additions and 14 deletions

View File

@ -287,21 +287,9 @@ public class Dispatcher implements RequestDispatcher
_contextHandler.handle(_path,baseRequest, (HttpServletRequest)request, (HttpServletResponse)response);
if (baseRequest.getResponse().isWriting())
if (!request.isAsyncStarted())
{
try {response.getWriter().close();}
catch(IllegalStateException e)
{
response.getOutputStream().close();
}
}
else
{
try {response.getOutputStream().close();}
catch(IllegalStateException e)
{
response.getWriter().close();
}
commitResponse(response,baseRequest);
}
}
}
@ -320,6 +308,33 @@ public class Dispatcher implements RequestDispatcher
}
private void commitResponse(ServletResponse response, Request baseRequest) throws IOException
{
if (baseRequest.getResponse().isWriting())
{
try
{
response.getWriter().close();
}
catch (IllegalStateException e)
{
response.getOutputStream().close();
}
}
else
{
try
{
response.getOutputStream().close();
}
catch (IllegalStateException e)
{
response.getWriter().close();
}
}
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */