tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeanfrancois Arcand <jfarc...@apache.org>
Subject Corner case with UnavailableException
Date Thu, 01 Dec 2005 16:37:19 GMT
Hi,

I'm currently looking at a corner case when an UnavailableException is 
thrown. Mainly, the Servlet is doing:

 >     public void service(HttpServletRequest req, HttpServletResponse resp)
 >         throws ServletException, IOException {
 >
 >         PrintWriter out = resp.getWriter();
 >         resp.setContentType("text/html");
 >
 >         out.println(" <HTML> ");
 >         out.flush();
 >         throw (new UnavailableException("Unavailable"));


The UnavailableException is permanent, so the Servlet.destroy() should 
be called(SRV.2.3.3.2). But that's not the case since the response has 
already been commited, so a java.lang.IllegalStateException will be 
thrown from StandardWrapperValve:

 >     242             } else if (available == Long.MAX_VALUE) {
 >     243 
response.sendError(HttpServletResponse.SC_NOT_FOUND,
 >     244 
sm.getString("standardWrapper.notFound",
 >     245                                         wrapper.getName()));
 >     246             }


 > java.lang.IllegalStateException: Cannot call sendError() after the 
response has been committed


I think we should avoid calling sendError is we know the response has 
been commited. Something like:

if (!response.isAppCommited()) {
....
}

What people thinks?

-- Jeanfrancois


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message