diff --git a/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java b/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java index a1bb43630..feabb2410 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisClusterConfiguration.java @@ -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 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 asMap(Collection 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 map = new HashMap<>(); map.put(REDIS_CLUSTER_NODES_CONFIG_PROPERTY, StringUtils.collectionToCommaDelimitedString(clusterHostAndPorts)); diff --git a/src/main/java/org/springframework/data/redis/connection/RedisSentinelConfiguration.java b/src/main/java/org/springframework/data/redis/connection/RedisSentinelConfiguration.java index 2840225cb..c4e07653f 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisSentinelConfiguration.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisSentinelConfiguration.java @@ -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 map = new HashMap<>(); map.put(REDIS_SENTINEL_MASTER_CONFIG_PROPERTY, master); diff --git a/src/test/java/org/springframework/data/redis/connection/RedisClusterConfigurationUnitTests.java b/src/test/java/org/springframework/data/redis/connection/RedisClusterConfigurationUnitTests.java index 3a8b02389..8a70b520b 100644 --- a/src/test/java/org/springframework/data/redis/connection/RedisClusterConfigurationUnitTests.java +++ b/src/test/java/org/springframework/data/redis/connection/RedisClusterConfigurationUnitTests.java @@ -95,7 +95,7 @@ class RedisClusterConfigurationUnitTests { } @Test // DATAREDIS-315 - void shouldBeCreatedCorrecltyGivenValidPropertySourceWithSingleHostPort() { + void shouldBeCreatedCorrectlyGivenValidPropertySourceWithSingleHostPort() { MockPropertySource propertySource = new MockPropertySource(); propertySource.setProperty("spring.redis.cluster.nodes", HOST_AND_PORT_1);