spring-projects / spring-projects/spring-session

Session.removeAttribute doesn't remove attribute from Redis

Open
#1,331 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

in: redis
Dominant language
Java
Stars
1.9k
Forks
1.2k
Avg merge
4h 27m
Merged PRs (30d)
55

Description

Hello,

The implementation within org.springframework.session.data.redis.RedisOperationsSessionRepository puts the attribute, to be removed, back into Redis and nulls out the value. This breaks consistency with the cached session attributes and creates an orphan in the Redis database. Furthermore, upon fail-over if the session is re-hydrated back from Redis the attribute will once again be cached and available to the web app, however this time without its value.

@Override
public void removeAttribute(String attributeName) {
this.cached.removeAttribute(attributeName);
this.putAndFlush(getSessionAttrNameKey(attributeName), null);
}

Shouldn't the entire attribute (key and value) be removed from Redis?

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 in org.springframework.session.data.redis.RedisOperationsSessionRepository and inspect removeAttribute(String attributeName), especially the putAndFlush call shown in the issue. Verify the Redis session data and cached attributes stay consistent after removal, including after rehydration from Redis.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, redis, spring
Domain
backend, databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.