spring-projects / spring-projects/spring-framework
ShallowEtagHeaderFilter returns empty response body for welcome page (GET /)
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 60.2k
- Forks
- 38.8k
- Avg merge
- 5d 2h
- Merged PRs (30d)
- 27
Description
When a ShallowEtagHeaderFilter bean is registered, the welcome page served at GET / returns an empty response body (content-length: 0). Requesting GET /index.html
directly works correctly and returns the full content.
Affected version: Spring Boot 4.0.5 (Spring Framework 7.0.6)
Steps to reproduce:
- Create a Spring Boot application with spring-boot-starter-web
- Place an index.html in src/main/resources/static/
- Register a ShallowEtagHeaderFilter bean
- Request GET /
Expected: The response body contains the content of index.html
Actual: The response body is empty with content-length: 0
Reproduction repository: https://github.com/LeovR/spring-boot-4-etag-filter
Run ./mvnw test — the welcomePageShouldReturnNonEmptyBody test fails, while directIndexHtmlShouldReturnNonEmptyBody passes.
This worked in Spring Boot 3 / Spring Framework 6, where ShallowEtagHeaderFilter used a plain ContentCachingResponseWrapper without the conditional caching behavior.
I am not sure whether this is a Spring Boot issue or a Spring Framework issue, since the ConditionalContentCachingResponseWrapper is part of spring-web.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running ./mvnw test in the linked reproduction repository and compare welcomePageShouldReturnNonEmptyBody with directIndexHtmlShouldReturnNonEmptyBody. Then inspect ShallowEtagHeaderFilter and ConditionalContentCachingResponseWrapper in spring-web. Done means GET / returns the index.html body, matching the direct request and passing the reproduction test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100