-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
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:
- ShallowEtagHeaderFilter setContentLength on include [SPR-11717] #16339 ShallowEtagHeaderFilter setContentLength on include
- ContentCachingResponseWrapper should NOT sendError() before write body [SPR-13004] #17596 ContentCachingResponseWrapper should NOT sendError() before write body