diff --git a/src/main/java/redis/clients/jedis/Pipeline.java b/src/main/java/redis/clients/jedis/Pipeline.java index c79c969..5dc3179 100644 --- a/src/main/java/redis/clients/jedis/Pipeline.java +++ b/src/main/java/redis/clients/jedis/Pipeline.java @@ -88,19 +88,20 @@ public class Pipeline extends MultiKeyPipelineBase { } /** - * Syncronize pipeline by reading all responses. This operation close the + * Synchronize pipeline by reading all responses. This operation close the * pipeline. In order to get return values from pipelined commands, capture * the different Response of the commands you execute. */ public void sync() { - List unformatted = client.getMany(getPipelinedResponseLength()); - for (Object o : unformatted) { - generateResponse(o); - } + if (getPipelinedResponseLength() > 0) { + List unformatted = client.getMany(getPipelinedResponseLength()); + for (Object o : unformatted) { + generateResponse(o); + } + } } - /** - * Syncronize pipeline by reading all responses. This operation close the + * Synchronize pipeline by reading all responses. This operation close the * pipeline. Whenever possible try to avoid using this version and use * Pipeline.sync() as it won't go through all the responses and generate the * right response type (usually it is a waste of time). @@ -108,17 +109,20 @@ public class Pipeline extends MultiKeyPipelineBase { * @return A list of all the responses in the order you executed them. */ public List syncAndReturnAll() { - List unformatted = client.getMany(getPipelinedResponseLength()); - List formatted = new ArrayList(); - - for (Object o : unformatted) { - try { - formatted.add(generateResponse(o).get()); - } catch (JedisDataException e) { - formatted.add(e); - } - } - return formatted; + if (getPipelinedResponseLength() > 0) { + List unformatted = client.getMany(getPipelinedResponseLength()); + List formatted = new ArrayList(); + for (Object o : unformatted) { + try { + formatted.add(generateResponse(o).get()); + } catch (JedisDataException e) { + formatted.add(e); + } + } + return formatted; + } else { + return java.util.Collections.emptyList(); + } } public Response discard() {