-
Notifications
You must be signed in to change notification settings - Fork 41.4k
Description
When accessing a missing page in webapp deployed in standalone container (Tomcat), after the calling of ErrorPageFilter.doFilter
which passes the ErrorWrapperResponse
and in the ApplicationDispatcher
which calls the response.getWriter
trigger from doForward
, the response.getWriter
will trigger ErrorWrapperResponse.getWriter
which calls the sendErrorIfNecessary
that triggers the container sendError
and committed the response which will cause the handleErrorStatus
in ErrorPageFilter
to fail when check
response is committed or not and prompt the error "Cannot forward to error page for request XXX as the response has already been committed. ...".
In the old version of ErrorWrapperResponse
, there is no override of the getWriter
, which won't trigger the sendError
that cause the committed response to happen early and can forward the error response to the custom error controller.
For now, when accessing a missing page in webapp, the tomcat generic error page will be displayed with the committed response error message instead of forwarding to the custom error controller.
Please fix the ErrorWrapperResponse.getWriter
.
#13951 says
So if we need customise error controller then we can't override configureDefaultServletHandling with configurer.enable. This problem will only occurred in Spring Boot 1.5.X with Apache Tomcat 8.5.X, while in Spring Boot 1.2.8 with Apache Tomcat 8.0.X, it won't happen.
not work for me.
spring-boot 2.1.3.RELEASE
tomcat 9.0.21
and I hadn't override DefaultServletHandlerConfigurer
with configurer.enable
.