diff --git a/Makefile b/Makefile index 7f3160abd..ace3b52b7 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ work/sentinel-%.conf: echo port $* >> $@ echo daemonize yes >> $@ + echo bind 0.0.0.0 >> $@ echo pidfile $(shell pwd)/work/sentinel-$*.pid >> $@ echo logfile $(shell pwd)/work/sentinel-$*.log >> $@ echo save \"\" >> $@ diff --git a/pom.xml b/pom.xml index e6d868411..2486f880c 100644 --- a/pom.xml +++ b/pom.xml @@ -23,7 +23,7 @@ 1.4.8 2.2 3.4.2.Final - 2.8.1 + 2.9.0 0.7 06052013 1.01 diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java index 6a7f75183..3862d9155 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnection.java @@ -770,7 +770,7 @@ public class JedisConnection extends AbstractRedisConnection { throw new InvalidDataAccessApiUsageException("No ongoing transaction. Did you forget to call multi?"); } List results = transaction.exec(); - return convertPipelineAndTxResults + return convertPipelineAndTxResults && results != null && !results.isEmpty() ? new TransactionResultConverter>(txResults, JedisConverters.exceptionConverter()) .convert(results) : results; diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java index 86fcb75b6..51721012a 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConnectionFactory.java @@ -97,6 +97,7 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean, private int timeout = Protocol.DEFAULT_TIMEOUT; private String password; private boolean usePool = true; + private boolean useSsl = false; private Pool pool; private JedisPoolConfig poolConfig = new JedisPoolConfig(); private int dbIndex = 0; @@ -264,8 +265,12 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean, * @since 1.4 */ protected Pool createRedisPool() { - return new JedisPool(getPoolConfig(), getShardInfo().getHost(), getShardInfo().getPort(), - getTimeoutFrom(getShardInfo()), getShardInfo().getPassword()); + + return useSsl + ? new JedisPool(getPoolConfig(), getShardInfo().getHost(), getShardInfo().getPort(), + getTimeoutFrom(getShardInfo()), getShardInfo().getPassword(), true) + : new JedisPool(getPoolConfig(), getShardInfo().getHost(), getShardInfo().getPort(), + getTimeoutFrom(getShardInfo()), getShardInfo().getPassword()); } private JedisCluster createCluster() { @@ -295,14 +300,15 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean, int redirects = clusterConfig.getMaxRedirects() != null ? clusterConfig.getMaxRedirects().intValue() : 5; - if (StringUtils.hasText(getPassword())) { - throw new IllegalArgumentException("Jedis does not support password protected Redis Cluster configurations!"); + if (poolConfig != null) { + return StringUtils.hasText(getPassword()) + ? new JedisCluster(hostAndPort, timeout, timeout, redirects, getPassword(), poolConfig) + : new JedisCluster(hostAndPort, timeout, redirects, poolConfig); } - if (poolConfig != null) { - return new JedisCluster(hostAndPort, timeout, redirects, poolConfig); - } - return new JedisCluster(hostAndPort, timeout, redirects, poolConfig); + return StringUtils.hasText(getPassword()) + ? new JedisCluster(hostAndPort, timeout, timeout, redirects, getPassword(), poolConfig) + : new JedisCluster(hostAndPort, timeout, redirects, poolConfig); } /* @@ -388,6 +394,26 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean, this.hostName = hostName; } + /** + * Sets whether to use SSL. + * + * @param useSsl {@literal true} to use SSL. + * @since 1.8 + */ + public void setUseSsl(boolean useSsl) { + this.useSsl = useSsl; + } + + /** + * Returns whether to use SSL. + * + * @return use of SSL + * @since 1.8 + */ + public boolean isUseSsl() { + return useSsl; + } + /** * Returns the password used for authenticating with the Redis server. * @@ -413,7 +439,6 @@ public class JedisConnectionFactory implements InitializingBean, DisposableBean, */ public int getPort() { return port; - } /** diff --git a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java index 0de0d960e..702ba2c38 100644 --- a/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java +++ b/src/test/java/org/springframework/data/redis/connection/AbstractConnectionIntegrationTests.java @@ -71,6 +71,7 @@ import org.springframework.data.redis.connection.RedisZSetCommands.Range; import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.SortParameters.Order; import org.springframework.data.redis.connection.StringRedisConnection.StringTuple; +import org.springframework.data.redis.connection.jedis.JedisConnectionFactory; import org.springframework.data.redis.core.Cursor; import org.springframework.data.redis.core.ScanOptions; import org.springframework.data.redis.core.StringRedisTemplate; @@ -830,7 +831,12 @@ public abstract class AbstractConnectionIntegrationTests { connection.set("testitnow", "somethingelse"); actual.add(connection.exec()); actual.add(connection.get("testitnow")); - verifyResults(Arrays.asList(new Object[] { null, "something" })); + + if (connectionFactory instanceof JedisConnectionFactory) { + verifyResults(Arrays.asList(new Object[] { Collections.emptyList(), "something" })); + } else { + verifyResults(Arrays.asList(new Object[] { null, "something" })); + } } @SuppressWarnings("unchecked") diff --git a/src/test/java/org/springframework/data/redis/core/RedisTemplateTests.java b/src/test/java/org/springframework/data/redis/core/RedisTemplateTests.java index a4ea5d763..ec290b1c2 100644 --- a/src/test/java/org/springframework/data/redis/core/RedisTemplateTests.java +++ b/src/test/java/org/springframework/data/redis/core/RedisTemplateTests.java @@ -72,6 +72,7 @@ import org.springframework.data.redis.serializer.StringRedisSerializer; * @author Christoph Strobl * @author Anqing Shao * @author Duobiao Ou + * @author Mark Paluch */ @RunWith(Parameterized.class) public class RedisTemplateTests { @@ -785,7 +786,12 @@ public class RedisTemplateTests { return operations.exec(); } }); - assertNull(results); + + if (redisTemplate.getConnectionFactory() instanceof JedisConnectionFactory) { + assertThat(results, is(empty())); + } else { + assertNull(results); + } assertThat(redisTemplate.opsForValue().get(key1), isEqual(value2)); } @@ -848,7 +854,13 @@ public class RedisTemplateTests { return operations.exec(); } }); - assertNull(results); + + if (redisTemplate.getConnectionFactory() instanceof JedisConnectionFactory) { + assertThat(results, is(empty())); + } else { + assertNull(results); + } + assertThat(redisTemplate.opsForValue().get(key1), isEqual(value2)); }