Avoid configuring the database number in JedisClientConfiguration used for Sentinels.
We now no longer configure the database number configured for data node access through JedisClientConfiguration instances that are used for Sentinel node connectivity. Previously, the configured database number lead to issuing a SELECT command on Sentinel that doesn't support database isolation. Fixes: #2103. Original Pull Request: #2112
This commit is contained in:
committed by
Christoph Strobl
parent
1b6737e9a5
commit
edde436f42
@@ -17,11 +17,14 @@ package org.springframework.data.redis.connection.jedis;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnRedisSentinelAvailable;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
@@ -48,6 +51,40 @@ class JedisConnectionFactorySentinelIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test // GH-2103
|
||||
void shouldConnectDataNodeCorrectly() {
|
||||
|
||||
RedisSentinelConfiguration configuration = new RedisSentinelConfiguration().master("mymaster")
|
||||
.sentinel("127.0.0.1", 26379).sentinel("127.0.0.1", 26380);
|
||||
configuration.setDatabase(5);
|
||||
|
||||
factory = new JedisConnectionFactory(configuration);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
RedisConnection connection = factory.getConnection();
|
||||
connection.flushAll();
|
||||
connection.set("key5".getBytes(), "value5".getBytes());
|
||||
|
||||
connection.select(0);
|
||||
assertThat(connection.exists("key5".getBytes())).isFalse();
|
||||
connection.close();
|
||||
}
|
||||
|
||||
@Test // GH-2103
|
||||
void shouldConnectSentinelNodeCorrectly() throws IOException {
|
||||
|
||||
RedisSentinelConfiguration configuration = new RedisSentinelConfiguration().master("mymaster")
|
||||
.sentinel("127.0.0.1", 26379).sentinel("127.0.0.1", 26380);
|
||||
configuration.setDatabase(5);
|
||||
|
||||
factory = new JedisConnectionFactory(configuration);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
RedisSentinelConnection sentinelConnection = factory.getSentinelConnection();
|
||||
assertThat(sentinelConnection.masters()).isNotNull();
|
||||
sentinelConnection.close();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-574, DATAREDIS-765
|
||||
void shouldInitializeWithSentinelConfiguration() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user