You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by la...@apache.org on 2001/01/12 05:39:06 UTC

cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core ContextManager.java Handler.java Response.java ResponseImpl.java ServletWrapper.java

larryi      01/01/11 20:39:06

  Modified:    src/share/org/apache/tomcat/core Tag: tomcat_32
                        ContextManager.java Handler.java Response.java
                        ResponseImpl.java ServletWrapper.java
  Log:
  Update handling so that when an included servlet throws an
  UnavailableException that isn't handled, it doesn't mark the callers
  as unavailable too.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.100.2.21 +6 -2      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.20
  retrieving revision 1.100.2.21
  diff -u -r1.100.2.20 -r1.100.2.21
  --- ContextManager.java	2001/01/04 21:23:59	1.100.2.20
  +++ ContextManager.java	2001/01/12 04:39:03	1.100.2.21
  @@ -1082,8 +1082,12 @@
   	    the client. AFAIK the trace is the _best_ debugger.
   	*/
   	if (t instanceof UnavailableException) {
  -	    int unavailableTime = ((UnavailableException)t).getUnavailableSeconds();
  -	    if( unavailableTime > 0 ) {
  +	    int unavailableTime = -1;
  +	    if ( !((UnavailableException)t).isPermanent() ) {
  +		unavailableTime = ((UnavailableException)t).getUnavailableSeconds();
  +		// if unavailable time not known, use 1 second
  +		if ( unavailableTime <= 0 )
  +		    unavailableTime = 1;
   		res.setHeader("Retry-After", Integer.toString(unavailableTime));
   	    }
   	    String msg=t.getMessage();
  
  
  
  1.7.2.8   +4 -3      jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java
  
  Index: Handler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v
  retrieving revision 1.7.2.7
  retrieving revision 1.7.2.8
  diff -u -r1.7.2.7 -r1.7.2.8
  --- Handler.java	2000/11/11 02:56:58	1.7.2.7
  +++ Handler.java	2001/01/12 04:39:03	1.7.2.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v 1.7.2.7 2000/11/11 02:56:58 larryi Exp $
  - * $Revision: 1.7.2.7 $
  - * $Date: 2000/11/11 02:56:58 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Handler.java,v 1.7.2.8 2001/01/12 04:39:03 larryi Exp $
  + * $Revision: 1.7.2.8 $
  + * $Date: 2001/01/12 04:39:03 $
    *
    * ====================================================================
    *
  @@ -260,6 +260,7 @@
   		}
   		context.log("Exception in init  " + ex.getMessage(), ex );
                   if (res.isIncluded()) { // Only propogate on includes
  +		    res.setErrorException(ex);
   		    // save error URI if necessary
   		    contextM.saveErrorURI( req, res );
                       if (ex instanceof IOException)
  
  
  
  1.22.2.3  +10 -0     jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java
  
  Index: Response.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Response.java,v
  retrieving revision 1.22.2.2
  retrieving revision 1.22.2.3
  diff -u -r1.22.2.2 -r1.22.2.3
  --- Response.java	2000/11/11 02:56:58	1.22.2.2
  +++ Response.java	2001/01/12 04:39:03	1.22.2.3
  @@ -143,6 +143,16 @@
        */
       public void setIncluded(boolean b);
   
  +    /** Set the error Exception that occurred during
  +	request processing.
  +     */
  +    public void setErrorException(Exception ex) ;
  +
  +    /** Get the Exception that occurred during request
  +	processing.
  +     */
  +    public Exception getErrorException() ;
  +
       /** Saves the request that originates an error.
        */
       public void setErrorURI(String uri) ;
  
  
  
  1.33.2.5  +12 -3     jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java
  
  Index: ResponseImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v
  retrieving revision 1.33.2.4
  retrieving revision 1.33.2.5
  diff -u -r1.33.2.4 -r1.33.2.5
  --- ResponseImpl.java	2000/11/11 02:56:58	1.33.2.4
  +++ ResponseImpl.java	2001/01/12 04:39:04	1.33.2.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v 1.33.2.4 2000/11/11 02:56:58 larryi Exp $
  - * $Revision: 1.33.2.4 $
  - * $Date: 2000/11/11 02:56:58 $
  + * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ResponseImpl.java,v 1.33.2.5 2001/01/12 04:39:04 larryi Exp $
  + * $Revision: 1.33.2.5 $
  + * $Date: 2001/01/12 04:39:04 $
    *
    * ====================================================================
    *
  @@ -108,6 +108,7 @@
       protected boolean commited = false;
       
       boolean notIncluded=true;
  +    Exception errorException=null;
       String errorURI=null;
   
       // default implementation will just append everything here
  @@ -155,6 +156,14 @@
   	    // move back to normal behavior.
   
   	}
  +    }
  +
  +    public void setErrorException(Exception ex) {
  +	errorException = ex;
  +    }
  +
  +    public Exception getErrorException() {
  +	return errorException;
       }
   
       public void setErrorURI(String uri) {
  
  
  
  1.60.2.5  +16 -5     jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ServletWrapper.java
  
  Index: ServletWrapper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Attic/ServletWrapper.java,v
  retrieving revision 1.60.2.4
  retrieving revision 1.60.2.5
  diff -u -r1.60.2.4 -r1.60.2.5
  --- ServletWrapper.java	2000/11/09 14:07:14	1.60.2.4
  +++ ServletWrapper.java	2001/01/12 04:39:05	1.60.2.5
  @@ -363,7 +363,7 @@
   
   	if( unavailable!=null  ) {
   	    // check servlet availability, throw appropriate exception if not
  -	    servletAvailable();
  +	    servletAvailable(req,res);
   	}
   
   	// called only if unavailable==null or timer expired.
  @@ -374,9 +374,10 @@
               throw e;
   	} catch ( UnavailableException e ) {
   	    // if unavailable not set, assume thrown from service(), not init()
  -	    if (unavailable == null) {
  +	    if (unavailable == null && res.getErrorException() != e) {
   		synchronized(this) {
   		    if (unavailable == null) {
  +			res.setErrorException(e);
   			unavailable = e;
   			// XXX if the UnavailableException is permanent we are supposed
   			// to destroy the servlet.  Synchronization of this destruction
  @@ -403,6 +404,9 @@
   	} else {
   	    servlet.service(req.getFacade(), res.getFacade());
   	}
  +	// clear any error exception since none were thrown
  +	res.setErrorException(null);
  +	res.setErrorURI(null);
       }
   
       // -------------------- Reloading --------------------
  @@ -472,21 +476,28 @@
       // -------------------- Unavailable --------------------
       /** Check if we can try again an init
        */
  -    private void servletAvailable()
  +    private void servletAvailable(Request req, Response res)
           throws IOException, ServletException
       {
   	// if permanently unavailable, rethrow exception
   	if (unavailable instanceof UnavailableException &&
  -		((UnavailableException)unavailable).isPermanent())
  +		((UnavailableException)unavailable).isPermanent()) {
  +	    res.setErrorException(unavailable);
  +	    contextM.saveErrorURI( req, res );
   	    throw (UnavailableException)unavailable;
  +	}
   	// we have a timer - maybe we can try again - how much
   	// do we have to wait - (in mSec)
   	long moreWaitTime=unavailableTime - System.currentTimeMillis();
   	if( moreWaitTime > 0 ) {
   	    // get seconds left, rounded up to at least one second
   	    int secs = (int)((moreWaitTime + 999) / 1000);
  +	    // set updated exception
  +	    res.setErrorException(new UnavailableException(
  +				unavailable.getMessage(), secs));
  +	    contextM.saveErrorURI( req, res );
   	    // throw updated exception
  -	    throw new UnavailableException(unavailable.getMessage(), secs);
  +	    throw (UnavailableException)res.getErrorException();
   	}
   	// we can try again
   	unavailable=null;