Re: [PATCH][4.0] remove spurious casts in ApplicationFilterChain

2001-12-30 Thread Daniel Rall

+1, old code was redundant.  Java should find the right method to call
based on object--not reference--type.

Christopher K. St. John [EMAIL PROTECTED] writes:

  The fall off the end of the chain code in
 ApplicationFilterChain.internalDoFilter checks if the
 passed in request and response are HttpServletRequest/
 Response objects. Based on the test, it casts the 
 objects and invokes servlet.service(). However, since
 the servlet member has a static type of javax.servlet.Servlet,
 the exact same method is called in both cases. The code
 operates correctly (since the non-http version of the 
 service() method eventually invokes the correct version
 of service()), but the test and cast are redundant and
 confusing. The following patch removes them:


 Index: ApplicationFilterChain.java
 ===
 RCS file: 
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationFilterChain.java,v
 retrieving revision 1.11
 diff -u -r1.11 ApplicationFilterChain.java
 --- ApplicationFilterChain.java 2001/10/11 23:30:58 1.11
 +++ ApplicationFilterChain.java 2001/12/28 19:06:24
 @@ -242,13 +242,7 @@
  try {
  support.fireInstanceEvent(InstanceEvent.BEFORE_SERVICE_EVENT,
servlet, request, response);
 -if ((request instanceof HttpServletRequest) 
 -(response instanceof HttpServletResponse)) {
 -servlet.service((HttpServletRequest) request,
 -(HttpServletResponse) response);
 -} else {
 -servlet.service(request, response);
 -}
 +servlet.service(request, response);
  support.fireInstanceEvent(InstanceEvent.AFTER_SERVICE_EVENT,
servlet, request, response);
  } catch (IOException e) {

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




[PATCH][4.0] remove spurious casts in ApplicationFilterChain

2001-12-28 Thread Christopher K. St. John


 The fall off the end of the chain code in
ApplicationFilterChain.internalDoFilter checks if the
passed in request and response are HttpServletRequest/
Response objects. Based on the test, it casts the 
objects and invokes servlet.service(). However, since
the servlet member has a static type of javax.servlet.Servlet,
the exact same method is called in both cases. The code
operates correctly (since the non-http version of the 
service() method eventually invokes the correct version
of service()), but the test and cast are redundant and
confusing. The following patch removes them:


Index: ApplicationFilterChain.java
===
RCS file: 
/home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/ApplicationFilterChain.java,v
retrieving revision 1.11
diff -u -r1.11 ApplicationFilterChain.java
--- ApplicationFilterChain.java 2001/10/11 23:30:58 1.11
+++ ApplicationFilterChain.java 2001/12/28 19:06:24
@@ -242,13 +242,7 @@
 try {
 support.fireInstanceEvent(InstanceEvent.BEFORE_SERVICE_EVENT,
   servlet, request, response);
-if ((request instanceof HttpServletRequest) 
-(response instanceof HttpServletResponse)) {
-servlet.service((HttpServletRequest) request,
-(HttpServletResponse) response);
-} else {
-servlet.service(request, response);
-}
+servlet.service(request, response);
 support.fireInstanceEvent(InstanceEvent.AFTER_SERVICE_EVENT,
   servlet, request, response);
 } catch (IOException e) {




-- 
Christopher St. John [EMAIL PROTECTED]
DistribuTopia http://www.distributopia.com

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]