tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geoff Soutter" <ge...@whitewolf.com.au>
Subject Re: Bug in org.apache.tomcat.core.ServletWrapper - UnavailableException ignored
Date Tue, 01 Aug 2000 01:26:00 GMT
Phil,

could you please stick this into the "interim" tomcat bug tracking system
thats set up at

http://znutar.cortexity.com/

thanks

Geoff

----- Original Message -----
From: "Phil Hanna" <Phil.Hanna@sas.com>
To: <tomcat-dev@jakarta.apache.org>
Sent: Tuesday, August 01, 2000 3:09 AM
Subject: Bug in org.apache.tomcat.core.ServletWrapper - UnavailableException
ignored


> 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 ) {
>    unavailable=ex;
>    unavailableTime=System.currentTimeMillis();
>    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 java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> public class BlowupServlet extends HttpServlet
> {
>    public void init(ServletConfig config)
>       throws ServletException
>    {
>       super.init(config);
>
>       // 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
>    {
>       response.setContentType("text/html");
>       response.getWriter().println
>          ("This should have blown up."
>          + " How did it get through?");
>    }
> }
>
> --- cut here ---
>
> Phil Hanna
> E-Commerce Solutions
> SAS Institute, Inc.
> Phil.Hanna@sas.com
> (919) 677-8000 x4284
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>


Mime
View raw message