DATAREDIS-765 - Enable pooling when configuring Jedis to use Redis Sentinel.
We now enable pool usage when configuring JedisConnectionFactory with RedisSentinelConfiguration to prevent accidental connections using the non-pooled standalone configuration. Jedis can operate with Sentinel only with pooling. We also reject calls to disable pooling when JedisConnectionFactory is configured to use Sentinel. Original Pull request: #307
This commit is contained in:
committed by
Christoph Strobl
parent
2fe048bfff
commit
b1f6bc7698
@@ -15,12 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection.jedis;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.test.util.RedisSentinelRule;
|
||||
|
||||
@@ -47,7 +48,7 @@ public class JedisConnectionFactorySentinelIntegrationTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-574
|
||||
@Test // DATAREDIS-574, DATAREDIS-765
|
||||
public void shouldInitializeWithSentinelConfiguration() {
|
||||
|
||||
JedisClientConfiguration clientConfiguration = JedisClientConfiguration.builder() //
|
||||
@@ -57,7 +58,10 @@ public class JedisConnectionFactorySentinelIntegrationTests {
|
||||
factory = new JedisConnectionFactory(SENTINEL_CONFIG, clientConfiguration);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
assertThat(factory.getConnection().getClientName(), equalTo("clientName"));
|
||||
RedisConnection connection = factory.getConnection();
|
||||
|
||||
assertThat(factory.getUsePool(), is(true));
|
||||
assertThat(connection.getClientName(), equalTo("clientName"));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-324
|
||||
|
||||
@@ -75,6 +75,14 @@ public class JedisConnectionFactoryUnitTests {
|
||||
verify(connectionFactory, never()).createRedisSentinelPool(any(RedisSentinelConfiguration.class));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class) // DATAREDIS-765
|
||||
public void shouldRejectPoolDisablingWhenSentinelConfigPresent() {
|
||||
|
||||
connectionFactory = new JedisConnectionFactory(new RedisSentinelConfiguration());
|
||||
|
||||
connectionFactory.setUsePool(false);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void shouldInitConnectionCorrectlyWhenClusterConfigPresent() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user