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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to