Skip to content

Commit 0e3377f

Browse files
committed
Redis Cluster: check port forwarding
1 parent 183005a commit 0e3377f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

driver/src/main/java/jdbc/client/impl/RedisJedisURIBase.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import redis.clients.jedis.HostAndPortMapper;
88
import redis.clients.jedis.JedisClientConfig;
99
import redis.clients.jedis.Protocol;
10+
import redis.clients.jedis.exceptions.JedisConnectionException;
1011

1112
import javax.net.ssl.SSLContext;
1213
import javax.net.ssl.SSLSocketFactory;
@@ -274,8 +275,12 @@ public ClientHostAndPortMapper(@NotNull Map<HostAndPort, HostAndPort> mapping) {
274275
}
275276

276277
@Override
277-
public HostAndPort getHostAndPort(HostAndPort hap) {
278-
return hap == null ? null : mapping.getOrDefault(hap, hap);
278+
public HostAndPort getHostAndPort(HostAndPort hap) throws JedisConnectionException {
279+
if (hap == null) return null;
280+
HostAndPort mappedHsp = mapping.get(hap);
281+
if (mappedHsp == null)
282+
throw new JedisConnectionException(String.format("Port forwarding is not specified for %s", hap));
283+
return mappedHsp;
279284
}
280285
}
281286
}

0 commit comments

Comments
 (0)