From 7db2de5b7c9d9d0764aa13381478502de623e029 Mon Sep 17 00:00:00 2001 From: yangfuhai Date: Wed, 14 Nov 2018 08:52:32 +0800 Subject: [PATCH] =?UTF-8?q?fixed=EF=BC=9A=E4=BF=AE=E5=A4=8D=20getHostAndPo?= =?UTF-8?q?rts=20=E5=8F=AF=E8=83=BD=E5=87=BA=E9=94=99=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/jboot/component/redis/JbootRedisConfig.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/jboot/component/redis/JbootRedisConfig.java b/src/main/java/io/jboot/component/redis/JbootRedisConfig.java index fcbfe437..cf21b165 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() { -- Gitee