tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@locus.apache.org
Subject cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/service/http HttpRequestAdapter.java
Date Fri, 18 Feb 2000 00:17:49 GMT
costin      00/02/17 16:17:49

  Modified:    src/share/org/apache/tomcat/core ContextManager.java
                        ServletWrapper.java
               src/share/org/apache/tomcat/service/http
                        HttpRequestAdapter.java
  Log:
  Few more errors in error processing.
  
  When we merged the error processing in ContextManager we removed few
  workarounds. For example Request should read the headers if
  the protocol is >=1.0, even if it doesn't like the URI.
  It worked before because it used a sendError() which didn't had any effect
  till after reading the headers. Now sendError() has effect, and we
  have to use setStatus() and read the headers.
  
  Also, we do print stack traces for all internal errors - that is a very
  important tool in debug, and we shouldn't hide them ! Even if it doesn't
  look good, if we have a NullPointer we should fix it, not hide it.
  
  As a result you'll see many traces when you run tomcat-test ( problems
  with jsp syntax).
  
  Revision  Changes    Path
  1.49      +3 -4      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.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- ContextManager.java	2000/02/17 23:37:47	1.48
  +++ ContextManager.java	2000/02/18 00:17:48	1.49
  @@ -569,7 +569,7 @@
   	    ctx=getContext("");
   	}
   	if(ctx.getDebug() > 0 ) ctx.log("In error handler " + code + " " + t +  " / " + req
);
  -	
  +	//	/*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
   	String path=null;
   	ServletWrapper errorServlet=null;
   
  @@ -578,7 +578,7 @@
   	    errorServlet=ctx.getServletByName("tomcat.errorPage");
   	} else if( req.getAttribute("javax.servlet.error.status_code") != null ||
   	    req.getAttribute("javax.servlet.error.exception_type")!=null) {
  -	    
  +	    //  /*DEBUG*/ try {throw new Exception(); } catch(Exception ex) {ex.printStackTrace();}
   	    if( ctx.getDebug() > 0 ) ctx.log( "Error: exception inside exception servlet "
+
   					      req.getAttribute("javax.servlet.error.status_code") + " " +
   					      req.getAttribute("javax.servlet.error.exception_type"));
  @@ -647,8 +647,7 @@
   	if( req.getAttribute("tomcat.servlet.error.handler") != null &&
   	    code >= 400 ) {
   	    // error page for 404 doesn't exist... ( or watchdog tests :-)
  -	    ctx.log( "Error/loop in default error handler " + req );
  -	    ctx.log( "Error/loop " + code + " " + t + " " +  path );
  +	    ctx.log( "Error/loop in default error handler " + req + " " + code + " " + t + " "
+  path );
   	} else {
   	    if( ctx.getDebug() > 0 ) ctx.log( "Error: Calling servlet " + errorServlet );
   	    req.setAttribute("tomcat.servlet.error.handler", errorServlet);
  
  
  
  1.30      +13 -5     jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
  retrieving revision 1.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- ServletWrapper.java	2000/02/17 07:52:20	1.29
  +++ ServletWrapper.java	2000/02/18 00:17:48	1.30
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
1.29 2000/02/17 07:52:20 costin Exp $
  - * $Revision: 1.29 $
  - * $Date: 2000/02/17 07:52:20 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ServletWrapper.java,v
1.30 2000/02/18 00:17:48 costin Exp $
  + * $Revision: 1.30 $
  + * $Date: 2000/02/18 00:17:48 $
    *
    * ====================================================================
    *
  @@ -358,8 +358,16 @@
   	    
   	    handleReload();
   
  -	    if( ! initialized )
  -		loadServlet();
  +	    if( ! initialized ) {
  +		try {
  +		    loadServlet();
  +		} catch(Exception ex ) {
  +		    // return not found
  +		    res.setStatus( 404 );
  +		    contextM.handleError( req, res, null, 404 );
  +		    return;
  +		}
  +	    }
   	    
   	    // XXX to expensive  per/request, un-load is not so frequent and
   	    // the API doesn't require a special state for destroy
  
  
  
  1.7       +10 -12    jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java
  
  Index: HttpRequestAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HttpRequestAdapter.java	2000/02/01 21:39:40	1.6
  +++ HttpRequestAdapter.java	2000/02/18 00:17:49	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
1.6 2000/02/01 21:39:40 costin Exp $
  - * $Revision: 1.6 $
  - * $Date: 2000/02/01 21:39:40 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/service/http/HttpRequestAdapter.java,v
1.7 2000/02/18 00:17:49 costin Exp $
  + * $Revision: 1.7 $
  + * $Date: 2000/02/18 00:17:49 $
    *
    * ====================================================================
    *
  @@ -120,10 +120,12 @@
   	//    return if an error was detected in processing the
   	//    request line
   
  -        if (response.getStatus() >=
  -	    HttpServletResponse.SC_BAD_REQUEST) {
  -            return;
  -	}
  +	// read headers if at least we have a protocol >=1.0, or the
  +	// error will be reported to early
  +	//         if (response.getStatus() >=
  +	// 	    HttpServletResponse.SC_BAD_REQUEST) {
  +	//             return;
  +	// 	}
   
   	// for 0.9, we don't have headers!
   	if(protocol!=null)
  @@ -227,11 +229,7 @@
   	}
   
   	if (requestErrorCode != 0) {
  -            try {
  -	        response.getFacade().sendError(requestErrorCode, msg);
  -	    } catch (IOException ioe) {
  -            }
  -
  +	    response.setStatus(requestErrorCode);
   	    return;
   	}
   
  
  
  

Mime
View raw message