spring-projects / spring-projects/spring-framework

ShallowEtagHeaderFilter returns empty response body for welcome page (GET /)

Open
#36,638 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

in: web status: waiting-for-triage
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:

  1. Create a Spring Boot application with spring-boot-starter-web
  2. Place an index.html in src/main/resources/static/
  3. Register a ShallowEtagHeaderFilter bean
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.