tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Koen Serneels" <koen.serne...@skynet.be>
Subject Registering Filters via API: isMatchAfter behaves weird
Date Wed, 04 Apr 2012 18:00:47 GMT
Hello,

 

I came across weird behavior using the JEE Servlet 3.0 API for adding
Filters with Tomcat 7.0.26
When I map two filters on the same URL and I use the "isMatchAfter"
attribute I would expect the filter having "isMatchAfter set to true to be
invoked last.

For example:

 

FilterRegistration.Dynamic registration1 =
servletContext.addFilter("filter1", new Filter1());

registration1.addMappingForUrlPatterns(null, true, "/Filter");

FilterRegistration.Dynamic registration2 =
servletContext.addFilter("filter2", new Filter2());

registration2.addMappingForUrlPatterns(null, false, "/Filter");

 

Filter1 prints "Filter1" to console when invoked, Filter2 prints "Filter2"
to console when invoked.

The "isMatchAfter" of filter one is set to true, which should mean it should
be invoked last when another filter is mapped on the same URL.

So I would expect that filter one is invoked AFTER filter two. This seems to
be inversed, Tomcat output:

 

Filter1

Filter2


I verified the example but with Glassfish 3.1.1 and this one delivered the
results as expected;

 

INFO: Filter2

INFO: Filter1

 

The flag does seem to have impact, because if I switch it: I set
isMatchAfter to false on filter one and isMatchAfter to true on filter 2 I
get this with tomcat:

 

Filter2

Filter1

 

So it looks like this flag was miss interpreted somehow and treated as a
"isMatchBefore".

 

Thanks,

 

Koen.


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message