Skip to content

RedisIndexedSessionRepository resolveDatabase method not support redisson client #3331

Open
@gabrielsky

Description

@gabrielsky

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

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