Filter's doFilter() method is getting invoked before servlet's init()
Environment
- Red Hat JBoss Enterprise Application Platform (EAP)
- 7.0.0
- 7.1.0
Issue
In JBoss Web (EAP 6), the code is executed in the following order at the first request.
- Filter.init()
- Servet.init()
- Filter.doFilter()
- Servlet.service()
While on Undertow (EAP 7) the order is as follows.
- Filter.init()
- Filter.doFilter()
- Servet.init()
- Servlet.service()
Resolution
Upgrade to the future version of EAP, provably 7.2.0 as of July 2017.
Root Cause
Both behaviours are compliant to the servlet specification but an effort has been implemented1 in the upstream to align the behaviour.
SBR
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.