You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2011/01/16 18:27:29 UTC

DO NOT REPLY [Bug 50597] Class.newInstance is used for Dynamic instance filters causing InstantiationException

https://issues.apache.org/bugzilla/show_bug.cgi?id=50597

--- Comment #1 from Ismael Juma <ml...@juma.me.uk> 2011-01-16 12:27:26 EST ---
The simple patch that fixes it for me is:


[ijuma@localhost]~/src/tomcat% svn diff
Index: java/org/apache/catalina/core/ApplicationFilterConfig.java
===================================================================
--- java/org/apache/catalina/core/ApplicationFilterConfig.java    (revision
1059421)
+++ java/org/apache/catalina/core/ApplicationFilterConfig.java    (working
copy)
@@ -367,10 +367,10 @@
             this.filter = null;

         } else {
-
-            // Allocate a new filter instance
-            getFilter();
-
+            if (filterDef.getFilter() == null) {
+              // Allocate a new filter instance
+              getFilter();
+            }
         }

     }

I don't know if this is the best way, but it works because after returning from
that method the following is executed in the constructor (which is the same
that getFilter does for the case where Tomcat has the class but not the
instance of Filter):

        if (filterDef.getFilter() != null) {
            this.filter = filterDef.getFilter();
            getInstanceManager().newInstance(filter);
            initFilter();
        }

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org