ShallowEtagHeaderFilter should write body early when HttpServletResponse.sendError() is called [SPR-11705] #16327
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
Dmitry Goncharov opened SPR-11705 and commented
Third party Servlet (in my case it's Jersey 2) is wrapped by org.springframework.web.filter.ShallowEtagHeaderFilter
In some cases Servlet need to write custom error response. Servlet do it in following way: add headers, write error response body and send error response code by calling response.sendError() method.
ShallowEtagHeaderFilter postpone response body writing, so actual body writing is performed in ShallowEtagHeaderFilter#copyBodyToResponse
after sendError method invocation.
response.sendError commits wrapped response, therefore ShallowEtagHeaderFilter#copyBodyToResponse is performed on committed response. This leads to wrong response content.
Proposed solution: Force content writing in org.springframework.web.filter.ShallowEtagHeaderFilter.ShallowEtagResponseWrapper when sendError or sendRedirect is called.
Affects: 3.0.5
Issue Links:
The text was updated successfully, but these errors were encountered: