Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50597
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 17 Jan 2011 17:12:36 +0000 (17:12 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 17 Jan 2011 17:12:36 +0000 (17:12 +0000)
Don't instantiate a new instance of a Filter if an instance was provided via the ServletContext.addFilter(String, Filter) method.
Patch provided by Ismael Juma.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1059993 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/core/ApplicationFilterConfig.java
webapps/docs/changelog.xml

index d34b085..f0e8ba9 100644 (file)
@@ -367,10 +367,10 @@ public final class ApplicationFilterConfig implements FilterConfig, Serializable
             this.filter = null;
 
         } else {
-
-            // Allocate a new filter instance
-            getFilter();
-
+            // Allocate a new filter instance if necessary
+            if (filterDef.getFilter() == null) {
+                getFilter();
+            }
         }
 
     }
index ecde6fe..93c10eb 100644 (file)
         <bug>50582</bug>: Refactor access logging so chunked encoding is not
         forced for all requests if bytes sent is logged. (markt)
       </fix>
+      <fix>
+        <bug>50597</bug>: Don&apos;t instantiate a new instance of a Filter if
+        an instance was provided via the
+        <code>ServletContext.addFilter(String, Filter)</code> method. Patch
+        provided by Ismael Juma. (markt)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Jasper">