You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When upgrading to spring-session-data-redis 4.1.0 we can no longer call org.springframework.session.data.redis.RedisIndexedSessionRepository#setRedisSessionMapper to set a custom session mapper in Kotlin.
This is because the signature of redisSessionMapper expects the BiFunction to return a non-null MapSession, whereas before this was not the case (the result could be a null session).
private@NullableRedisSessiongetSession(Stringid, booleanallowExpired) {
// omitted for brevityMapSessionloaded = this.redisSessionMapper.apply(id, entries);
if (loaded == null || (!allowExpired && loaded.isExpired())) {
returnnull;
}
// omitted for brevity
}
To Reproduce
The custom mapper below fails to compile in Kotlin because it returns null when loading an invalid session causes an IllegalStateException to be thrown:
Hi team! It looks like we just missed a @nullable on the BiFunction for redisSessionMapper, which is making the Kotlin compiler complain. Since getSession is already built to handle nulls safely, this should be a pretty quick fix.
I'd love to pick this up! I can add the missing annotations and write a quick Kotlin test to prove the fix works. Just let me know if you're good with me opening a PR for this.
Activity
Mhmoud803 commentedon Jun 30, 2026
Hi team! It looks like we just missed a @nullable on the BiFunction for redisSessionMapper, which is making the Kotlin compiler complain. Since getSession is already built to handle nulls safely, this should be a pretty quick fix.
I'd love to pick this up! I can add the missing annotations and write a quick Kotlin test to prove the fix works. Just let me know if you're good with me opening a PR for this.
spring-projectsGH-3857: Allow redisSessionMapper to return null MapSe…
Allow RedisSessionMapper to Return Null