From 5e484f9c79144d1350812d04684db02c1aa47d3c Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 4 Feb 2016 16:08:59 +0100 Subject: [PATCH] Fix NPE in when command output is null #187 --- .../cluster/ClusterDistributionChannelWriter.java | 5 ++++- .../redis/cluster/AdvancedClusterClientTest.java | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/lambdaworks/redis/cluster/ClusterDistributionChannelWriter.java b/src/main/java/com/lambdaworks/redis/cluster/ClusterDistributionChannelWriter.java index 048d160f78..b380aaa178 100644 --- a/src/main/java/com/lambdaworks/redis/cluster/ClusterDistributionChannelWriter.java +++ b/src/main/java/com/lambdaworks/redis/cluster/ClusterDistributionChannelWriter.java @@ -96,7 +96,10 @@ public > C write(C command) { channelWriter = writer.defaultWriter; } - commandToSend.getOutput().setError((String) null); + if(command.getOutput() != null){ + commandToSend.getOutput().setError((String) null); + } + if (channelWriter != null && channelWriter != this && channelWriter != defaultWriter) { return channelWriter.write((C) commandToSend); } diff --git a/src/test/java/com/lambdaworks/redis/cluster/AdvancedClusterClientTest.java b/src/test/java/com/lambdaworks/redis/cluster/AdvancedClusterClientTest.java index ef76d7478d..37cea23a28 100644 --- a/src/test/java/com/lambdaworks/redis/cluster/AdvancedClusterClientTest.java +++ b/src/test/java/com/lambdaworks/redis/cluster/AdvancedClusterClientTest.java @@ -484,6 +484,19 @@ public void pipelining() throws Exception { } + + @Test + public void transactions() throws Exception { + + commands.multi(); + commands.set(key, value); + commands.discard(); + + commands.multi(); + commands.set(key, value); + commands.exec(); + } + protected String value(int i) { return value + "-" + i; }