spring-projects / spring-projects/spring-session

Multiple sessions are created when SessionRepositoryFilter precede ShallowEtagHeaderFilter

Open
#132 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Multiple sessions are created when SessionRepositoryFilter precede ShallowEtagHeaderFilter. The reason being ShallowEtagHeaderFilter wraps the response with ShallowEtagResponseWrapper, which maintains an internal stream and commits the response just by copying the internal stream directly to the native httpresponse stream. Thus it bypass all HttpResponseWrappers in between including SessionRepositoryResponseWrapper, so the onResponseCommitted method is not getting called when the response is actually committed by ShallowEtagHeaderFilter.

When the control reaches SessionRepositoryFilter, response is already committed, so the newly added cookie header is not sent to the client. As a workaround, i moved SessionRepositoryFilter after ShallowEtagHeaderFilter in the filter chain and it works well.

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 reproducing the filter-chain ordering described for SessionRepositoryFilter and ShallowEtagHeaderFilter, focusing on how ShallowEtagResponseWrapper copies its internal stream to the native response. Compare that path with SessionRepositoryResponseWrapper and its onResponseCommitted handling. Done means the session cookie is sent and only one session is created when the filters are ordered as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.