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

RedisIndexedSessionRepository resolveDatabase method not support redisson client

Open gabrielsky opened this issue 11 months ago • 0 comments

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;
	}

gabrielsky avatar Jan 23 '25 04:01 gabrielsky