Skip to content

ShallowEtagHeaderFilter should write body early when HttpServletResponse.sendError() is called [SPR-11705] #16327

@spring-projects-issues

Description

@spring-projects-issues

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:

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions