tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Hanna <>
Subject Bug in org.apache.tomcat.core.ServletWrapper - UnavailableExcepti on ignored
Date Mon, 31 Jul 2000 17:09:26 GMT
The servlet API says that a servlet cannot be placed into service if the init() method throws
a ServletException.  However, Tomcat does not respect this restriction.  If a servlet throws
an UnavailableException in init(), the servlet is loaded anyway and requests get through to
doGet().  This may possibly relate to this code in ServletWrapper.initServlet():

catch( UnavailableException ex ) {
   unavailableTime += ex.getUnavailableSeconds() * 1000;
since ex.getUnavailableSeconds() returns -1 when the UnavailableException is permanent.

Here is a minimal servlet that will demonstrate the bug:

--- cut here ---

import javax.servlet.*;
import javax.servlet.http.*;

public class BlowupServlet extends HttpServlet
   public void init(ServletConfig config)
      throws ServletException

      // Intentionally throw an UnavailableException
      // to prevent the servlet from being placed
      // into service

      throw new UnavailableException
         ("Never accept requests!");

   public void doGet(
         HttpServletRequest request,
         HttpServletResponse response)
      throws ServletException, IOException
         ("This should have blown up."
         + " How did it get through?");

--- cut here ---

Phil Hanna
E-Commerce Solutions
SAS Institute, Inc.
(919) 677-8000 x4284

View raw message