Catch IOException when writing our response so that we don't freak out if the
client ungracefully stops listening to us. git-svn-id: https://samskivert.googlecode.com/svn/trunk@2227 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -448,14 +448,14 @@ public class DispatcherServlet extends HttpServlet
|
||||
protected void doRequest (HttpServletRequest request, HttpServletResponse response)
|
||||
throws ServletException, IOException
|
||||
{
|
||||
Context context = null;
|
||||
InvocationContext context = null;
|
||||
try {
|
||||
context = new InvocationContext(request, response);
|
||||
setContentType(request, response);
|
||||
|
||||
Template template = handleRequest(request, response, context);
|
||||
if (template != null) {
|
||||
mergeTemplate(template, context, response);
|
||||
mergeTemplate(template, context);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
@@ -524,12 +524,12 @@ public class DispatcherServlet extends HttpServlet
|
||||
*
|
||||
* @param template template object returned by the {@link #handleRequest} method.
|
||||
* @param context context created by the {@link #createContext} method.
|
||||
* @param response servlet reponse (use this to get the output stream or writer).
|
||||
*/
|
||||
protected void mergeTemplate (Template template, Context context, HttpServletResponse response)
|
||||
protected void mergeTemplate (Template template, InvocationContext context)
|
||||
throws ResourceNotFoundException, ParseErrorException, MethodInvocationException,
|
||||
IOException, UnsupportedEncodingException, Exception
|
||||
UnsupportedEncodingException, IOException, Exception
|
||||
{
|
||||
HttpServletResponse response = context.getResponse();
|
||||
ServletOutputStream output = response.getOutputStream();
|
||||
// ASSUMPTION: response.setContentType() has been called.
|
||||
String encoding = response.getCharacterEncoding();
|
||||
@@ -544,6 +544,11 @@ public class DispatcherServlet extends HttpServlet
|
||||
}
|
||||
template.merge(context, vw);
|
||||
|
||||
} catch (IOException ioe) {
|
||||
// the client probably crashed or aborted the connection ungracefully, so use log.info
|
||||
log.info("Failed to write response [uri=" + context.getRequest().getRequestURI() +
|
||||
", error=" + ioe + "]");
|
||||
|
||||
} finally {
|
||||
if (vw != null) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user