diff --git a/src/main/java/io/jboot/component/redis/JbootRedisConfig.java b/src/main/java/io/jboot/component/redis/JbootRedisConfig.java index fcbfe43786e29da6ee2ca183ed7bdbab7aa6dd0b..cf21b1656d19efabb7f6fc91db2777406590dcd5 100644 --- a/src/main/java/io/jboot/component/redis/JbootRedisConfig.java +++ b/src/main/java/io/jboot/component/redis/JbootRedisConfig.java @@ -217,15 +217,18 @@ public class JbootRedisConfig { } public Set getHostAndPorts() { - Set haps = new HashSet<>(); + Set hostAndPortSet = new HashSet<>(); String[] hostAndPortStrings = host.split(","); for (String hostAndPortString : hostAndPortStrings) { + if (StrUtils.isBlank(hostAndPortString)) continue; String[] hostAndPorts = hostAndPortString.split(":"); - HostAndPort hap = new HostAndPort(hostAndPorts[0], Integer.valueOf(hostAndPorts[1])); - haps.add(hap); + String host = hostAndPorts[0]; + int port = hostAndPorts.length > 1 ? Integer.parseInt(hostAndPorts[1]) : getPort(); + + hostAndPortSet.add(new HostAndPort(host, port)); } - return haps; + return hostAndPortSet; } public String getSerializer() {