-
Notifications
You must be signed in to change notification settings - Fork 6k
OnCommittedResponseWrapper fails on static resources served by Tomcat 8.5 #7261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Confirmed. I've stopped with the debugger at https://github.com/apache/tomcat/blob/8.5.45/java/org/apache/catalina/servlets/DefaultServlet.java#L1063 To give some context: In my spring-mvc web-app, I let tomcat serve static resources (from web-fragment jar dependencies from |
@danielwegener Thanks for the report. Can you please put together a minimal sample to reproduce the issue? |
Here comes the reproducer (sort of, not necessarily tomcat specific): https://gist.github.com/danielwegener/6fe53c3f4625c1761de4507a3dbefe2b When calling |
Thanks @danielwegener! Can you please turn that into a sample application that I can run rather than a gist? |
Add setContentLengthLong tracking to OnCommittedResponseWrapper in order to detect commits on servlets that use setContentLengthLong to announce the entity size they are about to write (as used in the Apache Tomcat's DefaultServlet). Fixes gh-7261
Add setContentLengthLong tracking to OnCommittedResponseWrapper in order to detect commits on servlets that use setContentLengthLong to announce the entity size they are about to write (as used in the Apache Tomcat's DefaultServlet). Fixes spring-projectsgh-7261
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 tomcatsorg.apache.catalina.servlets.DefaultServlet
usesServletResponse.setContentLengthLong
(see https://github.com/apache/tomcat/blob/8.5.45/java/org/apache/catalina/servlets/DefaultServlet.java#L1063) instead ofServletResponse.setContentLength
, which is not covered byOnCommittedResponseWrapper
(seespring-security/web/src/main/java/org/springframework/security/web/util/OnCommittedResponseWrapper.java
Line 67 in f3cdd44
Keep up the good work!
The text was updated successfully, but these errors were encountered: