From 39dc3579cf95e7550af4464134765a1739c7ad7f Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 28 Jan 2016 15:07:36 +0300 Subject: [PATCH] Connection timeout error message fixed --- .../connection/MasterSlaveConnectionManager.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java b/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java index 446ac3541..06c93ac65 100644 --- a/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java +++ b/src/main/java/org/redisson/connection/MasterSlaveConnectionManager.java @@ -203,19 +203,20 @@ public class MasterSlaveConnectionManager implements ConnectionManager { SingleEntry entry = new SingleEntry(slots, this, config); Future f = entry.setupMasterEntry(config.getMasterAddress().getHost(), config.getMasterAddress().getPort()); if (!f.awaitUninterruptibly(config.getConnectTimeout(), TimeUnit.MILLISECONDS)) { - throw new RedisConnectionException("Can't connect to server " + config.getMasterAddress()); + throw new RedisConnectionException("Can't connect to server " + config.getMasterAddress() + " due to connection timeout (" + config.getConnectTimeout() + " ms) has reached!", f.cause()); } addEntry(singleSlotRange, entry); } else { MasterSlaveEntry entry = new MasterSlaveEntry(slots, this, config); List> fs = entry.initSlaveBalancer(); + for (Future future : fs) { + if (!future.awaitUninterruptibly(config.getConnectTimeout(), TimeUnit.MILLISECONDS)) { + throw new RedisConnectionException("Can't connect to slave server due to connection timeout (" + config.getConnectTimeout() + " ms) has reached!", future.cause()); + } + } Future f = entry.setupMasterEntry(config.getMasterAddress().getHost(), config.getMasterAddress().getPort()); if (!f.awaitUninterruptibly(config.getConnectTimeout(), TimeUnit.MILLISECONDS)) { - throw new RedisConnectionException("Can't connect to server " + config.getMasterAddress()); - } - fs.add(f); - for (Future future : fs) { - future.syncUninterruptibly(); + throw new RedisConnectionException("Can't connect to server " + config.getMasterAddress() + " due to connection timeout (" + config.getConnectTimeout() + " ms) has reached!", f.cause()); } addEntry(singleSlotRange, entry); }