You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a class is together filter and listener, for example @Component class Together implements Filter, ServletRequestListener, it is only filter, not a listener.
The reason in org.springframework.boot.web.servlet.ServletContextInitializerBeans#seen;
if something is registered as filter, it became seen and cannot be registered as listener
That is not natural, because
Implementing one interface does not invalidate other. If developer decides that one beans serves for 2 purposes, it must be accepted or rejected as a bug
For tracing scenario it is natural, that tracing starts when tracing header is available and lasts until request is destroyed. So closing tracing code in single class is natural choice
It it not a big problem and workaround is easy, but it seems to be an inconsistency bug
The text was updated successfully, but these errors were encountered:
Thanks for the report. Things have been this way since 1.1 (if not earlier) so I think we may need to tread a little carefully when changing the behaviour in case doing so has unwanted side effects. I think it may be better to treat this as an enhancement, particularly as there's a workaround, and add support for beans that implement more the one contract from the Servlet API being registered multiple times in 3.3.
wilkinsona
changed the title
Bean can't be a Filter and ServletRequestListener together
Create multiple registrations for beans that implement multiple Servlet API contracts
Jan 8, 2024
When a class is together filter and listener, for example
@Component class Together implements Filter, ServletRequestListener
, it is only filter, not a listener.The reason in org.springframework.boot.web.servlet.ServletContextInitializerBeans#seen;
if something is registered as filter, it became seen and cannot be registered as listener
That is not natural, because
It it not a big problem and workaround is easy, but it seems to be an inconsistency bug
The text was updated successfully, but these errors were encountered: