I deployed my Spring Boot Web application on WildFly 8.1
, but now I have some trouble.
When application was deployed, FilterRegistrationBeans
register Servlet Filters. I know FilterRegistrationBean
s are oredered by AnnotationAwareOrderComparator
, and those filters are registerd by that order. But when I access my application, Undertow calls filters by reversed order.
For example, if Spring Boot register filters like that:
- errorPageFilter
- metricFilter (from Spring Boot actuator)
- characterEncodingFilter
- hiddenHttpMethodFilter
- springSecurityFilterChain (from Spring Security)
Undertow call those filters like that:
- springSecurityFilterChain
- hiddenHttpMethodFilter
- characterEncodingFilter
- metricFilter
- errorPageFilter
How can I specify those filters order correctly? Some filter's order (like org.springframework.boot.context.web.ErrorPageFilter
) was hard-coded in source, I can't specify that.
This appears to be an Undertow bug that occurs when matchAfter is false in FilterRegistrationImpl#addMappingForUrlPatterns, instead of inserting the filter before all declared filters it inserts it before all filters.