tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lar...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ContextManager.java
Date Thu, 09 Nov 2000 13:40:49 GMT
larryi      00/11/09 05:40:49

  Modified:    src/share/org/apache/tomcat/core Tag: tomcat_32
                        ContextManager.java
  Log:
  Moved UnavailableException handling from ServletWrapper to
  ContextManger's handleError method.
  
  This allows UnavailableExceptions to be handled by a call to handleErro()
  from Handler's service() method, along with other exceptions.  This is cleaner
  than trying to keep handling for UnavailableExceptions local to
  ServletWrapper when exceptions are being propagated.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.100.2.15 +22 -1     jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java
  
  Index: ContextManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ContextManager.java,v
  retrieving revision 1.100.2.14
  retrieving revision 1.100.2.15
  diff -u -r1.100.2.14 -r1.100.2.15
  --- ContextManager.java	2000/11/04 22:33:58	1.100.2.14
  +++ ContextManager.java	2000/11/09 13:40:48	1.100.2.15
  @@ -1060,6 +1060,9 @@
        * or use the default handler.
        */
       void handleError( Request req, Response res , Throwable t  ) {
  +	// if error already handled
  +	if (res.isErrorHandled())
  +	    return;
   	Context ctx = req.getContext();
   	if(ctx==null) {
   	    ctx=getContext("");
  @@ -1069,7 +1072,22 @@
   	    Note that it is _WRONG_ to send the trace back to
   	    the client. AFAIK the trace is the _best_ debugger.
   	*/
  -	if( t instanceof IllegalStateException ) {
  +	if (t instanceof UnavailableException) {
  +	    int unavailableTime = ((UnavailableException)t).getUnavailableSeconds();
  +	    if( unavailableTime > 0 ) {
  +		res.setHeader("Retry-After", Integer.toString(unavailableTime));
  +	    }
  +	    String msg=t.getMessage();
  +	    ctx.log( "UnavailableException in: " + req +
  +			", time remaining " + unavailableTime + " seconds : " + msg, t);
  +	    req.setAttribute("javax.servlet.error.message", msg );
  +	    res.setStatus(HttpServletResponse.SC_SERVICE_UNAVAILABLE); // 503
  +	    handleStatus( req, res, HttpServletResponse.SC_SERVICE_UNAVAILABLE );
  +	    // indicate error handling has been called
  +	    res.setErrorHandled(true);
  +	    return;
  +	}
  +	else if( t instanceof IllegalStateException ) {
   	    ctx.log("IllegalStateException in: " + req  + " " +
   		    t.getMessage() );
   	} else if( t instanceof org.apache.jasper.JasperException ) {
  @@ -1133,6 +1151,9 @@
           } catch( ServletException e) {
               ;   // ASSERT: Only thrown by included servlets
           }
  +
  +	// indicate error handling has been called
  +	res.setErrorHandled(true);
       }
   
       public ServletWrapper getHandlerForPath( Context ctx, String path ) {
  
  
  

Mime
View raw message