You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@locus.apache.org on 2000/03/21 20:19:41 UTC
cvs commit: jakarta-tomcat/src/share/org/apache/tomcat/core BufferedServletOutputStream.java Context.java ContextManager.java ResponseImpl.java
costin 00/03/21 11:19:40
Modified: src/share/org/apache/tomcat/core
BufferedServletOutputStream.java Context.java
ContextManager.java ResponseImpl.java
Log:
Fix for bug in RequestInterceptor calling - some methods were not
called/implemented.
Thanks Harish <ha...@postmark.net> for finding this one.
Note that pre/postService is called twice for servlets invoked via
InvokerServlet - if you depend on that it's possible to do a quick fix,
otherwise it'll be post 3.1.
Revision Changes Path
1.10 +8 -4 jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java
Index: BufferedServletOutputStream.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- BufferedServletOutputStream.java 2000/02/03 07:11:51 1.9
+++ BufferedServletOutputStream.java 2000/03/21 19:19:39 1.10
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java,v 1.9 2000/02/03 07:11:51 costin Exp $
- * $Revision: 1.9 $
- * $Date: 2000/02/03 07:11:51 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/BufferedServletOutputStream.java,v 1.10 2000/03/21 19:19:39 costin Exp $
+ * $Revision: 1.10 $
+ * $Date: 2000/03/21 19:19:39 $
*
* ====================================================================
*
@@ -239,9 +239,13 @@
sendHeaders();
committed = true;
}
-
+
if (bufferCount > 0) {
// out.write(buffer, 0, bufferCount);
+ Request req=resA.getRequest();
+ ContextManager cm=req.getContextManager();
+
+ cm.doBeforeCommit( req, resA );
doWrite( buffer, 0, bufferCount );
}
}
1.70 +12 -0 jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java
Index: Context.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/Context.java,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -r1.69 -r1.70
--- Context.java 2000/03/18 00:04:18 1.69
+++ Context.java 2000/03/21 19:19:40 1.70
@@ -882,6 +882,12 @@
@deprecated
*/
public ContextInterceptor[] getContextInterceptors() {
+ if( contextInterceptors.size() == 0 ) {
+ // this context was not set up with individual interceptors.
+ // XXX no test done for context-specific interceptors, this will be the normal
+ // case, we need to find out what is the best behavior and config
+ return contextM.getContextInterceptors();
+ }
if( cInterceptors == null || cInterceptors.length != contextInterceptors.size()) {
cInterceptors=new ContextInterceptor[contextInterceptors.size()];
for( int i=0; i<cInterceptors.length; i++ ) {
@@ -907,6 +913,12 @@
@deprecated
*/
public RequestInterceptor[] getRequestInterceptors() {
+ if( requestInterceptors.size() == 0 ) {
+ // this context was not set up with individual interceptors.
+ // XXX no test done for context-specific interceptors, this will be the normal
+ // case, we need to find out what is the best behavior and config
+ return contextM.getRequestInterceptors();
+ }
if( rInterceptors == null || rInterceptors.length != requestInterceptors.size()) {
rInterceptors=new RequestInterceptor[requestInterceptors.size()];
for( int i=0; i<rInterceptors.length; i++ ) {
1.63 +15 -0 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.62
retrieving revision 1.63
diff -u -r1.62 -r1.63
--- ContextManager.java 2000/03/21 01:27:08 1.62
+++ ContextManager.java 2000/03/21 19:19:40 1.63
@@ -385,6 +385,7 @@
}
public void addContextInterceptor( ContextInterceptor ci) {
+ if(debug>0) log("<l:contextInterceptor javaClass=\"" + ci.getClass().getName() + "\" />");
contextInterceptors.addElement( ci );
}
@@ -601,6 +602,20 @@
int doBeforeBody( Request req, Response res ) {
for( int i=0; i< requestInterceptors.size(); i++ ) {
((RequestInterceptor)requestInterceptors.elementAt(i)).beforeBody( req, res );
+ }
+ return 0;
+ }
+
+ int doBeforeCommit( Request req, Response res ) {
+ for( int i=0; i< requestInterceptors.size(); i++ ) {
+ ((RequestInterceptor)requestInterceptors.elementAt(i)).beforeCommit( req, res );
+ }
+ return 0;
+ }
+
+ int doAfterBody( Request req, Response res ) {
+ for( int i=0; i< requestInterceptors.size(); i++ ) {
+ ((RequestInterceptor)requestInterceptors.elementAt(i)).afterBody( req, res );
}
return 0;
}
1.16 +4 -3 jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java
Index: ResponseImpl.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ResponseImpl.java 2000/02/16 17:13:23 1.15
+++ ResponseImpl.java 2000/03/21 19:19:40 1.16
@@ -1,7 +1,7 @@
/*
- * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java,v 1.15 2000/02/16 17:13:23 costin Exp $
- * $Revision: 1.15 $
- * $Date: 2000/02/16 17:13:23 $
+ * $Header: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/core/ResponseImpl.java,v 1.16 2000/03/21 19:19:40 costin Exp $
+ * $Revision: 1.16 $
+ * $Date: 2000/03/21 19:19:40 $
*
* ====================================================================
*
@@ -176,6 +176,7 @@
writer.close();
}
out.reallyFlush();
+ request.getContextManager().doAfterBody(request, this);
out.close();
} catch (SocketException e) {
if(request!=null) request.getContext().log("Socket Exception" + request.getRequestURI());