Skip to content

Regression: ShallowEtagHeaderFilter does not add Etag header for ResponseEntity returning methods [SPR-13717] #18290

Closed

Description

@spring-projects-issues

Jan Gaedicke opened SPR-13717 and commented

As we updated our spring dependencies from 4.0.8.RELEASE to 4.2.3.RELEASE the ShallowEtagHeaderFilter stopped working for spring controller methods that return a ResponseEntity. The effect is that no "Etag" header is added to the response.

The problem is, that the HttpEntityMethodProcessor flushes the HttpServletResponse and the ShallowEtagHeaderFilter refuses to add the header if the response is committed.

As a workaround we have implemented the flushBuffer method in the ContentCachingResponseWrapper and delay the original flushBuffer call until copyBodyToResponse is called.

You can find a small spring-boot app using a tomcat to reproduce this bug at github:
https://github.com/jgaedicke/ShallowEtagHeaderFilter-bug-demo.


Affects: 4.2.2, 4.2.3

Reference URL: https://github.com/jgaedicke/ShallowEtagHeaderFilter-bug-demo

Issue Links:

Referenced from: commits 9d9433a

Activity

  1. spring-projects-issues commented on Nov 23, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Looking at the version history, I assume this does not happen with 4.1.8, i.e. it's a regression in the 4.2 line?

    Brian Clozel, this seems to be a side effect of your changes around #13194...

    Juergen

  2. spring-projects-issues commented on Nov 24, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

    I fixed this issue by not delegating the flushBuffer call to the actual response.
    Indeed, multiple parts of Spring can commit the response, making it impossible for the filter to act on it.

  3. spring-projects-issues commented on Nov 25, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    Jan Gaedicke, could you please give a recent 4.2.4.BUILD-SNAPSHOT a try and let us know whether it works for you now?

    Juergen

  4. spring-projects-issues commented on Nov 26, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Jan Gaedicke commented

    Great, thanks for the quick fix. It works for me. Any ideas when the next release will be available?

  5. spring-projects-issues commented on Nov 26, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Brian Clozel commented

    Thanks for the feedback!
    For now it's scheduled on December 22nd; you can follow its status here: https://jira.spring.io/browse/SPR/fixforversion/15353/

  6. spring-projects-issues commented on Nov 26, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Juergen Hoeller commented

    In this particular case, Dec 22 has to be seen "on Dec 22 at the latest". We might pull it forward by a week or so. In any case, we'll keep the release target on JIRA up to date.

    Juergen

  7. added
    type: bug
    in: web
    on Jan 11, 2019
  8. added this to the 4.2.4 milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: webtype: bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions