spring-projects / spring-projects/spring-session
RedisIndexedSessionRepository resolveDatabase method not support redisson client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.2k
- Avg merge
- 4h 27m
- Merged PRs (30d)
- 55
Description
Describe the bug
"The RedisIndexedSessionRepository has a method called resolveDatabase() that retrieves the Redis database currently in use. However, when using Redisson, it always returns DEFAULT_DATABASE. This is because Redisson implements a different RedisConnectionFactory named org.redisson.spring.data.connection.RedissonConnectionFactory
private int resolveDatabase() {
if (ClassUtils.isPresent("io.lettuce.core.RedisClient", null)
&& getRedisConnectionFactory() instanceof LettuceConnectionFactory) {
return ((LettuceConnectionFactory) getRedisConnectionFactory()).getDatabase();
}
if (ClassUtils.isPresent("redis.clients.jedis.Jedis", null)
&& getRedisConnectionFactory() instanceof JedisConnectionFactory) {
return ((JedisConnectionFactory) getRedisConnectionFactory()).getDatabase();
}
return RedisIndexedSessionRepository.DEFAULT_DATABASE;
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in RedisIndexedSessionRepository.resolveDatabase() and inspect how the repository identifies LettuceConnectionFactory and JedisConnectionFactory. Compare that logic with RedissonConnectionFactory and verify that the configured Redis database is returned instead of DEFAULT_DATABASE; add or update coverage if the surrounding tests expose this method's behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, redis, spring
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100