larryi 00/12/16 11:04:28
Modified: src/facade22/org/apache/tomcat/facade ServletHandler.java
src/share/org/apache/tomcat/core Handler.java
Log:
Fix handling in ServletHandler for UnavailableException throw in service().
Move isIncluded() test from core to facade22.
Revision Changes Path
1.7 +22 -14
jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletHandler.java
Index: ServletHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-tomcat/src/facade22/org/apache/tomcat/facade/ServletHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ServletHandler.java 2000/12/15 03:43:43 1.6
+++ ServletHandler.java 2000/12/16 19:04:26 1.7
@@ -420,13 +420,7 @@
Exception ex=getErrorException();
// save error state on request and response
saveError( req, res, ex );
- // if in included, defer handling to higher level
- if (res.isIncluded()) return;
- // handle init error since at top level
- if( ex instanceof ClassNotFoundException )
- contextM.handleStatus( req, res, 404 );
- else
- contextM.handleError( req, res, ex );
+ handleInitError( req, res, ex );
return;
}
}
@@ -453,11 +447,7 @@
// if unavailable
if( ! checkAvailable( req, res ) ) {
- // if in included, defer handling to higher level
- if ( res.isIncluded() )
- return;
- // otherwise handle error
- contextM.handleError( req, res, req.getErrorException());
+ handleServiceError( req, res, req.getErrorException());
return; // we can't handle it
}
@@ -494,9 +484,9 @@
setState( STATE_DISABLED );
// XXX spec says we must destroy the servlet
}
- if ( null != getErrorException() ) {
+ if ( null == getErrorException() ) {
synchronized(this) {
- if ( null!= getErrorException() ) {
+ if ( null == getErrorException() ) {
if ( state == STATE_DISABLED )
// servlet exception state
setErrorException( ex );
@@ -506,8 +496,26 @@
}
}
}
+ throw ex;
}
// other exceptions will be thrown
+ }
+
+ protected void handleInitError( Request req, Response res, Throwable t )
+ {
+ // if in included, defer handling to higher level
+ if (res.isIncluded()) return;
+ if( t instanceof ClassNotFoundException )
+ contextM.handleStatus( req, res, 404 );
+ else
+ contextM.handleError( req, res, t );
+ }
+
+ protected void handleServiceError( Request req, Response res, Throwable t )
+ {
+ // if in included, defer handling to higher level
+ if (res.isIncluded()) return;
+ contextM.handleError( req, res, t );
}
// -------------------- Unavailable --------------------
1.31 +4 -9 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.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- Handler.java 2000/12/14 07:10:58 1.30
+++ Handler.java 2000/12/16 19:04:27 1.31
@@ -235,21 +235,16 @@
reqI[i].postService( req, res );
}
- // if no error
- if( serviceException == null ) return;
-
- // if in included, defer handling to higher level
- if (res.isIncluded()) return;
-
- // handle original error since at top level
- contextM.handleError( req, res, res.getErrorException() );
+ // if error, handle
+ if( serviceException != null )
+ handleServiceError( req, res, serviceException );
}
// -------------------- methods you can override --------------------
protected void handleServiceError( Request req, Response res, Throwable t )
{
- // XXX TODO
+ contextM.handleError( req, res, t );
}
/** Reload notification. This hook is called whenever the