spring-projects / spring-projects/spring-session

Issue in Redis Session Serialization after Upgrading from Spring Boot 3.3.3 to 3.4.3

Open
#3,347 8 comments 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description:
Hello :)
After upgrading from Spring Boot 3.3.3 to 3.4.3, my application encounters an issue where certain sessions stored in Redis no longer include the creationTime attribute. This results in a persistent exception being thrown during request handling:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception
java.lang.IllegalStateException: creationTime key must not be null
	at org.springframework.session.data.redis.RedisSessionMapper.handleMissingKey(RedisSessionMapper.java:62)
	at org.springframework.session.data.redis.RedisSessionMapper.apply(RedisSessionMapper.java:72)
	at org.springframework.session.data.redis.RedisSessionMapper.apply(RedisSessionMapper.java:37)
	at org.springframework.session.data.redis.RedisIndexedSessionRepository.getSession(RedisIndexedSessionRepository.java:535)
	at org.springframework.session.data.redis.RedisIndexedSessionRepository.findById(RedisIndexedSessionRepository.java:500)
	at org.springframework.session.data.redis.RedisIndexedSessionRepository.findById(RedisIndexedSessionRepository.java:267)
	at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.getRequestedSession(SessionRepositoryFilter.java:352)
	at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.getSession(SessionRepositoryFilter.java:286)
	at org.springframework.session.web.http.SessionRepositoryFilter$SessionRepositoryRequestWrapper.getSession(SessionRepositoryFilter.java:193)
	at jakarta.servlet.http.HttpServletRequestWrapper.getSession(HttpServletRequestWrapper.java:221)
	at org.springframework.security.web.context.HttpSessionSecurityContextRepository.lambda$loadDeferredContext$0(HttpSessionSecurityContextRepository.java:143)
	at org.springframework.security.web.context.SupplierDeferredSecurityContext.init(SupplierDeferredSecurityContext.java:67)
	at org.springframework.security.web.context.SupplierDeferredSecurityContext.get(SupplierDeferredSecurityContext.java:52)

Steps to Reproduce:

Use Spring Boot 3.4.3 with Spring Session Data Redis.

Upgrade from Spring Boot 3.3.3 to 3.4.3.

Start the application and attempt to retrieve a session from Redis.

Observe the IllegalStateException: creationTime key must not be null error.

Expected Behavior:

The session should be deserialized correctly, retaining all required attributes, including creationTime.

Actual Behavior:

Some sessions retrieved from Redis do not contain creationTime, leading to an IllegalStateException.

Workaround:

No known workaround at this time. Clearing Redis storage does not resolve the issue permanently.

Environment:

Spring Boot Version: 3.4.3

Spring Data Session Version: 3.4.2

Java Version: 17

Any additional dependencies or configurations that might be relevant.

Additional Context:

This issue was not present in Spring Boot 3.3.3.

The problem appears to be related to session serialization/deserialization changes in Redis.

Would appreciate any guidance on resolving this issue. Thanks!

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 with RedisSessionMapper.java around handleMissingKey and apply, then trace RedisIndexedSessionRepository.getSession and findById from the reported stack trace. Reproduce the upgrade from Spring Boot 3.3.3 to 3.4.3 using Spring Session Data Redis and inspect affected Redis sessions. Done means sessions containing the required creationTime attribute deserialize successfully without the IllegalStateException.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.