From 40e7184ea756dd60dab6a5be84378e9d9cd21b0c Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Wed, 19 Aug 2015 21:10:38 +0200 Subject: [PATCH] Align exceptions when invoking commands #119 Throw RedisException instead of future-transport on disconnected state when reconnect is disabled. --- .../java/com/lambdaworks/redis/protocol/CommandHandler.java | 5 ++--- src/test/java/com/lambdaworks/redis/ClientTest.java | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/lambdaworks/redis/protocol/CommandHandler.java b/src/main/java/com/lambdaworks/redis/protocol/CommandHandler.java index d3a9b635d5..92c7775eb0 100644 --- a/src/main/java/com/lambdaworks/redis/protocol/CommandHandler.java +++ b/src/main/java/com/lambdaworks/redis/protocol/CommandHandler.java @@ -178,9 +178,8 @@ public > C write(C command) { } if ((channel == null || !isConnected()) && !clientOptions.isAutoReconnect()) { - command.completeExceptionally(new RedisException( - "Connection is in a disconnected state and reconnect is disabled. Commands are not accepted.")); - return command; + throw new RedisException( + "Connection is in a disconnected state and reconnect is disabled. Commands are not accepted."); } try { diff --git a/src/test/java/com/lambdaworks/redis/ClientTest.java b/src/test/java/com/lambdaworks/redis/ClientTest.java index 511169e041..242b8efe2e 100644 --- a/src/test/java/com/lambdaworks/redis/ClientTest.java +++ b/src/test/java/com/lambdaworks/redis/ClientTest.java @@ -124,7 +124,7 @@ public void disconnectedConnectionWithoutReconnect() throws Exception { connection.quit(); Wait.untilTrue(() -> !connection.isOpen()).waitOrTimeout(); try { - connection.get(key).get(); + connection.get(key); } catch (Exception e) { assertThat(e).hasRootCauseInstanceOf(RedisException.class).hasMessageContaining( "Connection is in a disconnected state and reconnect is disabled");