spring-session icon indicating copy to clipboard operation
spring-session copied to clipboard

After `changeSessionId`, expirationStore(ordered set) lost the new sessionId

Open hdsuperman opened this issue 9 months ago • 0 comments

Describe the bug

After changeSessionId, expirationStore(ordered set) lost the new sessionId

To Reproduce

  1. config SortedSetRedisSessionExpirationStore for expirationStore
  2. Create a new session and save it
  3. FindById to get the previously saved session
  4. Call changeSessionId and save it
  5. You can see in the expiration kv of redis that the new sessionId does not exist

Expected behavior

The old sessionId should be deleted and the new sessionId should be appended to the sorted set of redis

Source

https://github.com/spring-projects/spring-session/blob/2353d8b3cec4f0ed104c45f10d01acf278fe1dad/spring-session-data-redis/src/main/java/org/springframework/session/data/redis/RedisIndexedSessionRepository.java#L994

How to fix

We can add a rename method to the RedisSessionExpirationStore interface

rename(String oldSessionId, String newSessionId, Integer expirationInMillis)

hdsuperman avatar Mar 26 '25 08:03 hdsuperman