Skip to content

RedisOperationsSessionRepository: SessionCreatedEvents don't contain RedisSession -> Session-Attributes cannot be modified in Listeners #1338

@ghost

Description

In our project we use org.springframework.session.web.http.SessionEventHttpSessionListenerAdapter to handle SessionCreatedEvents. Unfortunately, the RedisOperationsSessionRepository only publishes SessionCreatedEvents containing a MapSession, instead of a RedisSession:

private void handleCreated(Map<Object, Object> loaded, String channel) {
String id = channel.substring(channel.lastIndexOf(":") + 1);
Session session = loadSession(id, loaded);
publishEvent(new SessionCreatedEvent(this, session));
}

Due to this, attributes set to this session by Listeners (e.g. org.springframework.web.util.HttpSessionMutexListener) will not be saved to Redis and are lost. This was not expected behaviour for us.

Changing Line 588 to
Session session = new RedisSession(loadSession(id, loaded));
as in


would propably solve the issue, but I don't know, whether this would induce other problems.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions