Skip to content

OnCommittedResponseWrapper fails on static resources served by Tomcat 8.5 #7261

@danielwegener

Description

@danielwegener

Component: spring-security-web-5.1.3.RELEASE.jar (also with latest 5.1.6)

TL;DR: Filters relying on OnCommittedResponseWrapper do not work when a response length is announced with ServletResponse.setContentLengthLong before it is written.

Hey guys. I've noticed, that my HeaderWriters are not triggered for responses served by Tomcats 8.5's default servlet. I've found that the OnCommittedResponseWrapper.onResponseCommitted is never triggered. Debugging through the filter chain I've noticed that tomcats org.apache.catalina.servlets.DefaultServlet uses ServletResponse.setContentLengthLong (see https://github.com/apache/tomcat/blob/8.5.45/java/org/apache/catalina/servlets/DefaultServlet.java#L1063) instead of ServletResponse.setContentLength, which is not covered by OnCommittedResponseWrapper (see

). Is there any reason why this method is not covered by committed-detection or is it simply an overlooked method during migration to servlet 3.1?

Keep up the good work!

Metadata

Metadata

Assignees

Labels

in: webAn issue in web modules (web, webmvc)status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions