diff --git a/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java b/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java index a01ff4d1bb..13f2730ab4 100644 --- a/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java +++ b/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java @@ -63,9 +63,6 @@ protected final Response appendCommand(CommandObject commandObject) { queue = pipelinedResponses.get(nodeKey); connection = connections.get(nodeKey); } else { - pipelinedResponses.putIfAbsent(nodeKey, new LinkedList<>()); - queue = pipelinedResponses.get(nodeKey); - Connection newOne = getConnection(nodeKey); connections.putIfAbsent(nodeKey, newOne); connection = connections.get(nodeKey); @@ -73,6 +70,9 @@ protected final Response appendCommand(CommandObject commandObject) { log.debug("Duplicate connection to {}, closing it.", nodeKey); IOUtils.closeQuietly(newOne); } + + pipelinedResponses.putIfAbsent(nodeKey, new LinkedList<>()); + queue = pipelinedResponses.get(nodeKey); } connection.sendCommand(commandObject.getArguments());