You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Nick Williams <ni...@nicholaswilliams.net> on 2013/09/23 22:47:29 UTC

OT: Adding Filters and odd WebLogic Behavior

This is very off topic, and for that I apologize. I'm working on fixing a bug in Log4j 2, and we've discovered something that just doesn't make any sense to me. I /believe/ it's a problem with WebLogic's implementation of the Servlet 3.0 specification, but I could be wrong, and based on my previous experience trying to communicate with WebLogic support, I figured I'd solicit some feedback from the Servlet spec experts on this list to see if I'm in the wrong before I try to bark up that tree again.

What we discovered is that if you add a filter programmatically using addFilter(String filterName, String className) or addFilter(String filterName, Class<? extends Filter> filterClass), everything works fine. The filter's init method is called during application startup, it is invoked in the proper place in the chain, and the destroy method is called during application shutdown, all in the right order. However, if you add the filter using addFilter(String filterName, Filter filter), this is not the case. The filter _is_ still invoked in the proper place in the chain, but its init method is _never_ called. WebLogic ignores the init method completely. The destroy method, however, _is_ still called on application shutdown.

Again, this is the _WebLogic_ behavior. I have not been able to duplicate this in Tomcat. Tomcat appears to function the same no matter which method I use to add the filter. Furthermore, I can't find anything in the spec that would support WebLogic's behavior. One thought thrown out was that WebLogic assumed you had already called the init method since you were passing in an instance, but I don't see anything in the spec that supports such an assumption.

Am I missing something? Or is WebLogic broken here, as I suspect?

Thanks,

Nick

(BTW, thankfully it doesn't matter to us which method we use, so we're just switching to a different method. But if it's a problem, WebLogic still needs to fix it.)

Re: OT: Adding Filters and odd WebLogic Behavior

Posted by Mark Thomas <ma...@apache.org>.
On 23/09/2013 13:47, Nick Williams wrote:

tldr: I'd say that is a WebLogic bug

> This is very off topic, and for that I apologize. I'm working on
> fixing a bug in Log4j 2, and we've discovered something that just
> doesn't make any sense to me. I /believe/ it's a problem with
> WebLogic's implementation of the Servlet 3.0 specification, but I
> could be wrong, and based on my previous experience trying to
> communicate with WebLogic support, I figured I'd solicit some
> feedback from the Servlet spec experts on this list to see if I'm in
> the wrong before I try to bark up that tree again.
> 
> What we discovered is that if you add a filter programmatically using
> addFilter(String filterName, String className) or addFilter(String
> filterName, Class<? extends Filter> filterClass), everything works
> fine. The filter's init method is called during application startup,
> it is invoked in the proper place in the chain, and the destroy
> method is called during application shutdown, all in the right order.
> However, if you add the filter using addFilter(String filterName,
> Filter filter), this is not the case. The filter _is_ still invoked
> in the proper place in the chain, but its init method is _never_
> called. WebLogic ignores the init method completely. The destroy
> method, however, _is_ still called on application shutdown.
> 
> Again, this is the _WebLogic_ behavior. I have not been able to
> duplicate this in Tomcat. Tomcat appears to function the same no
> matter which method I use to add the filter. Furthermore, I can't
> find anything in the spec that would support WebLogic's behavior. One
> thought thrown out was that WebLogic assumed you had already called
> the init method since you were passing in an instance, but I don't
> see anything in the spec that supports such an assumption.
> 
> Am I missing something? Or is WebLogic broken here, as I suspect?

Servlet 3.0 section 6.2.1 is fairly strong evidence for a WebLogic bug.

As is the Javadoc for Filter.init()

You might want to check the equivalent addServlet method as well.

Mark

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