diff --git a/src/main/java/org/redisson/CommandExecutorService.java b/src/main/java/org/redisson/CommandExecutorService.java index 068ee4076..06660b91f 100644 --- a/src/main/java/org/redisson/CommandExecutorService.java +++ b/src/main/java/org/redisson/CommandExecutorService.java @@ -440,7 +440,7 @@ public class CommandExecutorService implements CommandExecutor { ex.set(new RedisTimeoutException()); final Timeout timeout = connectionManager.getTimer().newTimeout(retryTimerTask, connectionManager.getConfig().getTimeout(), TimeUnit.MILLISECONDS); - Future connectionFuture; + final Future connectionFuture; if (readOnlyMode) { if (client != null) { connectionFuture = connectionManager.connectionReadOp(source, command, client); @@ -542,7 +542,11 @@ public class CommandExecutorService implements CommandExecutor { if (future.isSuccess()) { R res = future.getNow(); if (res instanceof RedisClientResult) { - ((RedisClientResult)res).setRedisClient(client); + RedisClient redisClient = client; + if (redisClient == null) { + redisClient = connectionFuture.getNow().getRedisClient(); + } + ((RedisClientResult)res).setRedisClient(redisClient); } mainPromise.setSuccess(res); } else {