Guard RedisClusterConfiguration.asMap and RedisSentinelConfiguration.asMap with Assert.noNullElements(…).
Closes #2167
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection;
|
||||
|
||||
import static org.springframework.util.Assert.*;
|
||||
import static org.springframework.util.StringUtils.*;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -91,7 +90,7 @@ public class RedisClusterConfiguration implements RedisConfiguration, ClusterCon
|
||||
*/
|
||||
public RedisClusterConfiguration(PropertySource<?> propertySource) {
|
||||
|
||||
notNull(propertySource, "PropertySource must not be null!");
|
||||
Assert.notNull(propertySource, "PropertySource must not be null!");
|
||||
|
||||
this.clusterNodes = new LinkedHashSet<>();
|
||||
|
||||
@@ -112,7 +111,7 @@ public class RedisClusterConfiguration implements RedisConfiguration, ClusterCon
|
||||
*/
|
||||
public void setClusterNodes(Iterable<RedisNode> nodes) {
|
||||
|
||||
notNull(nodes, "Cannot set cluster nodes to 'null'.");
|
||||
Assert.notNull(nodes, "Cannot set cluster nodes to 'null'.");
|
||||
|
||||
this.clusterNodes.clear();
|
||||
|
||||
@@ -137,7 +136,7 @@ public class RedisClusterConfiguration implements RedisConfiguration, ClusterCon
|
||||
*/
|
||||
public void addClusterNode(RedisNode node) {
|
||||
|
||||
notNull(node, "ClusterNode must not be 'null'.");
|
||||
Assert.notNull(node, "ClusterNode must not be 'null'.");
|
||||
this.clusterNodes.add(node);
|
||||
}
|
||||
|
||||
@@ -266,8 +265,8 @@ public class RedisClusterConfiguration implements RedisConfiguration, ClusterCon
|
||||
|
||||
String[] args = split(hostAndPort, ":");
|
||||
|
||||
notNull(args, "HostAndPort need to be seperated by ':'.");
|
||||
isTrue(args.length == 2, "Host and Port String needs to specified as host:port");
|
||||
Assert.notNull(args, "HostAndPort need to be seperated by ':'.");
|
||||
Assert.isTrue(args.length == 2, "Host and Port String needs to specified as host:port");
|
||||
return new RedisNode(args[0], Integer.valueOf(args[1]));
|
||||
}
|
||||
|
||||
@@ -278,7 +277,8 @@ public class RedisClusterConfiguration implements RedisConfiguration, ClusterCon
|
||||
*/
|
||||
private static Map<String, Object> asMap(Collection<String> clusterHostAndPorts, int redirects) {
|
||||
|
||||
notNull(clusterHostAndPorts, "ClusterHostAndPorts must not be null!");
|
||||
Assert.notNull(clusterHostAndPorts, "ClusterHostAndPorts must not be null!");
|
||||
Assert.noNullElements(clusterHostAndPorts, "ClusterHostAndPorts must not contain null elements!");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(REDIS_CLUSTER_NODES_CONFIG_PROPERTY, StringUtils.collectionToCommaDelimitedString(clusterHostAndPorts));
|
||||
|
||||
@@ -354,6 +354,7 @@ public class RedisSentinelConfiguration implements RedisConfiguration, SentinelC
|
||||
|
||||
Assert.hasText(master, "Master address must not be null or empty!");
|
||||
Assert.notNull(sentinelHostAndPorts, "SentinelHostAndPorts must not be null!");
|
||||
Assert.noNullElements(sentinelHostAndPorts, "ClusterHostAndPorts must not contain null elements!");
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put(REDIS_SENTINEL_MASTER_CONFIG_PROPERTY, master);
|
||||
|
||||
Reference in New Issue
Block a user