From 7d247ca26efdb85b36fac12c0cae9d6ffe2bb777 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Sun, 16 Jan 2022 11:50:16 +0600 Subject: [PATCH 1/7] Support exclusive XPENDING range from params --- src/main/java/redis/clients/jedis/Jedis.java | 4 + .../clients/jedis/MultiNodePipelineBase.java | 4 + .../java/redis/clients/jedis/Pipeline.java | 4 + .../redis/clients/jedis/TransactionBase.java | 4 + .../redis/clients/jedis/UnifiedJedis.java | 4 + .../jedis/commands/StreamBinaryCommands.java | 5 +- .../jedis/commands/StreamCommands.java | 2 + .../StreamPipelineBinaryCommands.java | 5 +- .../commands/StreamPipelineCommands.java | 2 + .../clients/jedis/params/XPendingParams.java | 92 +++++++++++++------ 10 files changed, 98 insertions(+), 28 deletions(-) diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index aa12c18eaa..c09fa3bc55 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -8780,7 +8780,11 @@ public StreamPendingSummary xpending(final String key, final String groupname) { return connection.executeCommand(commandObjects.xpending(key, groupname)); } + /** + * @deprecated Use {@link Jedis#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. + */ @Override + @Deprecated public List xpending(final String key, final String groupname, final StreamEntryID start, final StreamEntryID end, final int count, final String consumername) { checkIsInMultiOrPipeline(); diff --git a/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java b/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java index ecbffae7b1..df52527ae6 100644 --- a/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java +++ b/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java @@ -1378,7 +1378,11 @@ public Response xpending(String key, String groupname) { return appendCommand(commandObjects.xpending(key, groupname)); } + /** + * @deprecated Use {@link MultiNodePipelineBase#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. + */ @Override + @Deprecated public Response> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return appendCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } diff --git a/src/main/java/redis/clients/jedis/Pipeline.java b/src/main/java/redis/clients/jedis/Pipeline.java index 008cf2d21e..2f2a04e188 100644 --- a/src/main/java/redis/clients/jedis/Pipeline.java +++ b/src/main/java/redis/clients/jedis/Pipeline.java @@ -1388,7 +1388,11 @@ public Response xpending(String key, String groupname) { return appendCommand(commandObjects.xpending(key, groupname)); } + /** + * @deprecated Use {@link Pipeline#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. + */ @Override + @Deprecated public Response> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return appendCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } diff --git a/src/main/java/redis/clients/jedis/TransactionBase.java b/src/main/java/redis/clients/jedis/TransactionBase.java index 18139b2784..fed592faa1 100644 --- a/src/main/java/redis/clients/jedis/TransactionBase.java +++ b/src/main/java/redis/clients/jedis/TransactionBase.java @@ -1432,7 +1432,11 @@ public Response xpending(String key, String groupname) { return appendCommand(commandObjects.xpending(key, groupname)); } + /** + * @deprecated Use {@link TransactionBase#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. + */ @Override + @Deprecated public Response> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return appendCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } diff --git a/src/main/java/redis/clients/jedis/UnifiedJedis.java b/src/main/java/redis/clients/jedis/UnifiedJedis.java index c59f02b3b2..2f543a2e01 100644 --- a/src/main/java/redis/clients/jedis/UnifiedJedis.java +++ b/src/main/java/redis/clients/jedis/UnifiedJedis.java @@ -2575,7 +2575,11 @@ public StreamPendingSummary xpending(String key, String groupname) { return executeCommand(commandObjects.xpending(key, groupname)); } + /** + * @deprecated Use {@link UnifiedJedis#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. + */ @Override + @Deprecated public List xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return executeCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } diff --git a/src/main/java/redis/clients/jedis/commands/StreamBinaryCommands.java b/src/main/java/redis/clients/jedis/commands/StreamBinaryCommands.java index b5e9c46007..ce1dc4caae 100644 --- a/src/main/java/redis/clients/jedis/commands/StreamBinaryCommands.java +++ b/src/main/java/redis/clients/jedis/commands/StreamBinaryCommands.java @@ -4,7 +4,6 @@ import java.util.Map; import redis.clients.jedis.params.*; -import redis.clients.jedis.resps.StreamFullInfo; public interface StreamBinaryCommands { @@ -42,6 +41,10 @@ default byte[] xadd(byte[] key, Map hash, XAddParams params) { Object xpending(byte[] key, byte[] groupname); + /** + * @deprecated Use {@link StreamBinaryCommands#xpending(byte[], byte[], redis.clients.jedis.params.XPendingParams)}. + */ + @Deprecated List xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername); List xpending(byte[] key, byte[] groupname, XPendingParams params); diff --git a/src/main/java/redis/clients/jedis/commands/StreamCommands.java b/src/main/java/redis/clients/jedis/commands/StreamCommands.java index b5000ed509..2872f8bfeb 100644 --- a/src/main/java/redis/clients/jedis/commands/StreamCommands.java +++ b/src/main/java/redis/clients/jedis/commands/StreamCommands.java @@ -153,7 +153,9 @@ default StreamEntryID xadd(String key, Map hash, XAddParams para * @param end * @param count * @param consumername + * @deprecated Use {@link StreamCommands#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. */ + @Deprecated List xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername); diff --git a/src/main/java/redis/clients/jedis/commands/StreamPipelineBinaryCommands.java b/src/main/java/redis/clients/jedis/commands/StreamPipelineBinaryCommands.java index f5028dfaa9..daa99da0fc 100644 --- a/src/main/java/redis/clients/jedis/commands/StreamPipelineBinaryCommands.java +++ b/src/main/java/redis/clients/jedis/commands/StreamPipelineBinaryCommands.java @@ -5,7 +5,6 @@ import redis.clients.jedis.Response; import redis.clients.jedis.params.*; -import redis.clients.jedis.resps.StreamFullInfo; public interface StreamPipelineBinaryCommands { // @@ -45,6 +44,10 @@ default Response xadd(byte[] key, Map hash, XAddParams p Response xpending(byte[] key, byte[] groupname); + /** + * @deprecated Use {@link StreamPipelineBinaryCommands#xpending(byte[], byte[], redis.clients.jedis.params.XPendingParams)}. + */ + @Deprecated Response> xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername); Response> xpending(byte[] key, byte[] groupname, XPendingParams params); diff --git a/src/main/java/redis/clients/jedis/commands/StreamPipelineCommands.java b/src/main/java/redis/clients/jedis/commands/StreamPipelineCommands.java index 5437abd0d1..b99d377c3c 100644 --- a/src/main/java/redis/clients/jedis/commands/StreamPipelineCommands.java +++ b/src/main/java/redis/clients/jedis/commands/StreamPipelineCommands.java @@ -154,7 +154,9 @@ default Response xadd(String key, Map hash, XAddP * @param end * @param count * @param consumername + * @deprecated Use {@link StreamPipelineCommands#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. */ + @Deprecated Response> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername); diff --git a/src/main/java/redis/clients/jedis/params/XPendingParams.java b/src/main/java/redis/clients/jedis/params/XPendingParams.java index 59273917fb..e162cf2b60 100644 --- a/src/main/java/redis/clients/jedis/params/XPendingParams.java +++ b/src/main/java/redis/clients/jedis/params/XPendingParams.java @@ -1,40 +1,77 @@ package redis.clients.jedis.params; import static redis.clients.jedis.Protocol.Keyword.IDLE; +import static redis.clients.jedis.Protocol.toByteArray; +import static redis.clients.jedis.util.SafeEncoder.encode; import redis.clients.jedis.CommandArguments; -import redis.clients.jedis.Protocol; import redis.clients.jedis.StreamEntryID; -import redis.clients.jedis.util.SafeEncoder; public class XPendingParams implements IParams { + private boolean legacy = true; private Long idle; - + private byte[] start; // TODO: final + private byte[] end; // TODO: final + private Integer count; // TODO: final private String consumer; - private StreamEntryID start; - - private StreamEntryID end; - - private Integer count; + /** + * @deprecated Use {@link XPendingParams#XPendingParams(redis.clients.jedis.StreamEntryID, redis.clients.jedis.StreamEntryID, int)}. + */ + @Deprecated + public XPendingParams() { + } + /** + * @deprecated Use {@link XPendingParams#xPendingParams(redis.clients.jedis.StreamEntryID, redis.clients.jedis.StreamEntryID, int)}. + */ + @Deprecated public static XPendingParams xPendingParams() { return new XPendingParams(); } + public XPendingParams(StreamEntryID start, StreamEntryID end, int count) { + this(start.toString(), end.toString(), count); + } + + public XPendingParams(String start, String end, int count) { + this(encode(start), encode(end), count); + } + + public XPendingParams(byte[] start, byte[] end, int count) { + this.legacy = false; + this.start = start; + this.end = end; + this.count = count; + } + + public static XPendingParams xPendingParams(StreamEntryID start, StreamEntryID end, int count) { + return new XPendingParams(start, end, count); + } + + public static XPendingParams xPendingParams(String start, String end, int count) { + return new XPendingParams(start, end, count); + } + + public static XPendingParams xPendingParams(byte[] start, byte[] end, int count) { + return new XPendingParams(start, end, count); + } + public XPendingParams idle(long idle) { this.idle = idle; return this; } + @Deprecated public XPendingParams start(StreamEntryID start) { - this.start = start; + this.start = encode(start.toString()); return this; } + @Deprecated public XPendingParams end(StreamEntryID end) { - this.end = end; + this.end = encode(end.toString()); return this; } @@ -52,28 +89,31 @@ public XPendingParams consumer(String consumer) { public void addParams(CommandArguments args) { if (idle != null) { - args.add(IDLE.getRaw()); - args.add(Protocol.toByteArray(idle)); - } - - if (start == null) { - args.add(SafeEncoder.encode("-")); - } else { - args.add(SafeEncoder.encode(start.toString())); + args.add(IDLE).add(toByteArray(idle)); } - if (end == null) { - args.add(SafeEncoder.encode("+")); + if (legacy) { + if (start == null) { + args.add(encode("-")); + } else { + args.add(start); + } + + if (end == null) { + args.add(encode("+")); + } else { + args.add(end); + } + + if (count != null) { + args.add(toByteArray(count)); + } } else { - args.add(SafeEncoder.encode(end.toString())); - } - - if (count != null) { - args.add(Protocol.toByteArray(count)); + args.add(start).add(end).add(toByteArray(count)); } if (consumer != null) { - args.add(SafeEncoder.encode(consumer)); + args.add(consumer); } } } From 0bcd995be23c783c1bd69e47cfed2f994747f31c Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Sun, 16 Jan 2022 11:57:14 +0600 Subject: [PATCH 2/7] CommandObjects --- src/main/java/redis/clients/jedis/CommandObjects.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/redis/clients/jedis/CommandObjects.java b/src/main/java/redis/clients/jedis/CommandObjects.java index 161dd3b32e..9d3916abc9 100644 --- a/src/main/java/redis/clients/jedis/CommandObjects.java +++ b/src/main/java/redis/clients/jedis/CommandObjects.java @@ -2228,6 +2228,10 @@ public final CommandObject xpending(String key, String gro BuilderFactory.STREAM_PENDING_SUMMARY); } + /** + * @deprecated Use {@link CommandObjects#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. + */ + @Deprecated public final CommandObject> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { CommandArguments args = commandArguments(XPENDING).key(key).add(groupname) @@ -2246,6 +2250,10 @@ public final CommandObject xpending(byte[] key, byte[] groupname) { BuilderFactory.RAW_OBJECT); } + /** + * @deprecated Use {@link CommandObjects#xpending(byte[], byte[], redis.clients.jedis.params.XPendingParams)}. + */ + @Deprecated public final CommandObject> xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, byte[] consumername) { CommandArguments args = commandArguments(XPENDING).key(key).add(groupname) From 72b65cf30b3f3c293c7b9c5e50e889585b2429d1 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Tue, 18 Jan 2022 19:46:10 +0600 Subject: [PATCH 3/7] Borrow test from #2818 Thanks mostly to @AvitalFineRedis --- .../commands/jedis/StreamsCommandsTest.java | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java index 432e6b8cac..57c7be1cad 100644 --- a/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java +++ b/src/test/java/redis/clients/jedis/commands/jedis/StreamsCommandsTest.java @@ -423,7 +423,6 @@ public void xreadGroupWithParams() { @Test public void xack() { - Map map = new HashMap(); map.put("f1", "v1"); jedis.xadd("xack-stream", (StreamEntryID) null, map); @@ -482,6 +481,29 @@ public void xpendingWithParams() { assertEquals(0, pendingRange.size()); } + @Test + public void xpendingRange() { + Map map = new HashMap<>(); + map.put("foo", "bar"); + StreamEntryID m1 = jedis.xadd("xpendeing-stream", (StreamEntryID) null, map); + StreamEntryID m2 = jedis.xadd("xpendeing-stream", (StreamEntryID) null, map); + jedis.xgroupCreate("xpendeing-stream", "xpendeing-group", null, false); + + // read 1 message from the group with each consumer + Map streamQeury = Collections.singletonMap( + "xpendeing-stream", StreamEntryID.UNRECEIVED_ENTRY); + jedis.xreadGroup("xpendeing-group", "consumer1", XReadGroupParams.xReadGroupParams().count(1), streamQeury); + jedis.xreadGroup("xpendeing-group", "consumer2", XReadGroupParams.xReadGroupParams().count(1), streamQeury); + + List response = jedis.xpending("xpendeing-stream", "xpendeing-group", + XPendingParams.xPendingParams("(0", "+", 5)); + assertEquals(2, response.size()); + assertEquals(m1, response.get(0).getID()); + assertEquals("consumer1", response.get(0).getConsumerName()); + assertEquals(m2, response.get(1).getID()); + assertEquals("consumer2", response.get(1).getConsumerName()); + } + @Test public void xclaimWithParams() { Map map = new HashMap<>(); From 3478c5541410b907660522f32de19bdddd3726e3 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Tue, 18 Jan 2022 19:59:21 +0600 Subject: [PATCH 4/7] add deprecation for binary in Jedis class --- src/main/java/redis/clients/jedis/Jedis.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index c09fa3bc55..ade7c86de8 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -4567,16 +4567,20 @@ public long xtrim(byte[] key, XTrimParams params) { } @Override - public List xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, - byte[] consumername) { + public Object xpending(final byte[] key, final byte[] groupname) { checkIsInMultiOrPipeline(); - return connection.executeCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); + return connection.executeCommand(commandObjects.xpending(key, groupname)); } + /** + * @deprecated Use {@link Jedis#xpending(byte[], byte[], redis.clients.jedis.params.XPendingParams)}. + */ @Override - public Object xpending(final byte[] key, final byte[] groupname) { + @Deprecated + public List xpending(byte[] key, byte[] groupname, byte[] start, byte[] end, int count, + byte[] consumername) { checkIsInMultiOrPipeline(); - return connection.executeCommand(commandObjects.xpending(key, groupname)); + return connection.executeCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } @Override From 7be1e8b7e30964dc916ed03ced2ffe7cf12632cf Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Tue, 18 Jan 2022 20:00:10 +0600 Subject: [PATCH 5/7] remove deprecations from 'base' classes --- src/main/java/redis/clients/jedis/MultiNodePipelineBase.java | 4 ---- src/main/java/redis/clients/jedis/Pipeline.java | 4 ---- src/main/java/redis/clients/jedis/TransactionBase.java | 4 ---- src/main/java/redis/clients/jedis/UnifiedJedis.java | 4 ---- 4 files changed, 16 deletions(-) diff --git a/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java b/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java index df52527ae6..ecbffae7b1 100644 --- a/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java +++ b/src/main/java/redis/clients/jedis/MultiNodePipelineBase.java @@ -1378,11 +1378,7 @@ public Response xpending(String key, String groupname) { return appendCommand(commandObjects.xpending(key, groupname)); } - /** - * @deprecated Use {@link MultiNodePipelineBase#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. - */ @Override - @Deprecated public Response> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return appendCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } diff --git a/src/main/java/redis/clients/jedis/Pipeline.java b/src/main/java/redis/clients/jedis/Pipeline.java index 2f2a04e188..008cf2d21e 100644 --- a/src/main/java/redis/clients/jedis/Pipeline.java +++ b/src/main/java/redis/clients/jedis/Pipeline.java @@ -1388,11 +1388,7 @@ public Response xpending(String key, String groupname) { return appendCommand(commandObjects.xpending(key, groupname)); } - /** - * @deprecated Use {@link Pipeline#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. - */ @Override - @Deprecated public Response> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return appendCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } diff --git a/src/main/java/redis/clients/jedis/TransactionBase.java b/src/main/java/redis/clients/jedis/TransactionBase.java index fed592faa1..18139b2784 100644 --- a/src/main/java/redis/clients/jedis/TransactionBase.java +++ b/src/main/java/redis/clients/jedis/TransactionBase.java @@ -1432,11 +1432,7 @@ public Response xpending(String key, String groupname) { return appendCommand(commandObjects.xpending(key, groupname)); } - /** - * @deprecated Use {@link TransactionBase#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. - */ @Override - @Deprecated public Response> xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return appendCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } diff --git a/src/main/java/redis/clients/jedis/UnifiedJedis.java b/src/main/java/redis/clients/jedis/UnifiedJedis.java index 2f543a2e01..c59f02b3b2 100644 --- a/src/main/java/redis/clients/jedis/UnifiedJedis.java +++ b/src/main/java/redis/clients/jedis/UnifiedJedis.java @@ -2575,11 +2575,7 @@ public StreamPendingSummary xpending(String key, String groupname) { return executeCommand(commandObjects.xpending(key, groupname)); } - /** - * @deprecated Use {@link UnifiedJedis#xpending(java.lang.String, java.lang.String, redis.clients.jedis.params.XPendingParams)}. - */ @Override - @Deprecated public List xpending(String key, String groupname, StreamEntryID start, StreamEntryID end, int count, String consumername) { return executeCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } From 1eb69479b6dd70809fc0c725b89cc9155c817d65 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Tue, 18 Jan 2022 20:05:41 +0600 Subject: [PATCH 6/7] modify XPendingParams --- .../clients/jedis/params/XPendingParams.java | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/main/java/redis/clients/jedis/params/XPendingParams.java b/src/main/java/redis/clients/jedis/params/XPendingParams.java index e162cf2b60..7ce3e687fd 100644 --- a/src/main/java/redis/clients/jedis/params/XPendingParams.java +++ b/src/main/java/redis/clients/jedis/params/XPendingParams.java @@ -2,19 +2,20 @@ import static redis.clients.jedis.Protocol.Keyword.IDLE; import static redis.clients.jedis.Protocol.toByteArray; -import static redis.clients.jedis.util.SafeEncoder.encode; +import static redis.clients.jedis.args.RawableFactory.from; import redis.clients.jedis.CommandArguments; import redis.clients.jedis.StreamEntryID; +import redis.clients.jedis.args.Rawable; public class XPendingParams implements IParams { private boolean legacy = true; private Long idle; - private byte[] start; // TODO: final - private byte[] end; // TODO: final - private Integer count; // TODO: final - private String consumer; + private Rawable start; // TODO: final + private Rawable end; // TODO: final + private int count = Integer.MIN_VALUE; // TODO: final + private Rawable consumer; /** * @deprecated Use {@link XPendingParams#XPendingParams(redis.clients.jedis.StreamEntryID, redis.clients.jedis.StreamEntryID, int)}. @@ -36,10 +37,14 @@ public XPendingParams(StreamEntryID start, StreamEntryID end, int count) { } public XPendingParams(String start, String end, int count) { - this(encode(start), encode(end), count); + this(from(start), from(end), count); } public XPendingParams(byte[] start, byte[] end, int count) { + this(from(start), from(end), count); + } + + private XPendingParams(Rawable start, Rawable end, int count) { this.legacy = false; this.start = start; this.end = end; @@ -65,13 +70,13 @@ public XPendingParams idle(long idle) { @Deprecated public XPendingParams start(StreamEntryID start) { - this.start = encode(start.toString()); + this.start = from(start.toString()); return this; } @Deprecated public XPendingParams end(StreamEntryID end) { - this.end = encode(end.toString()); + this.end = from(end.toString()); return this; } @@ -81,7 +86,12 @@ public XPendingParams count(int count) { } public XPendingParams consumer(String consumer) { - this.consumer = consumer; + this.consumer = from(consumer); + return this; + } + + public XPendingParams consumer(byte[] consumer) { + this.consumer = from(consumer); return this; } @@ -94,18 +104,18 @@ public void addParams(CommandArguments args) { if (legacy) { if (start == null) { - args.add(encode("-")); + args.add("-"); } else { args.add(start); } if (end == null) { - args.add(encode("+")); + args.add("+"); } else { args.add(end); } - if (count != null) { + if (count != Integer.MIN_VALUE) { args.add(toByteArray(count)); } } else { From 37e05341f96b29a6c3008ab967f4815a61c0fa25 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Tue, 18 Jan 2022 20:08:32 +0600 Subject: [PATCH 7/7] undo reorder to avoid confusion --- src/main/java/redis/clients/jedis/Jedis.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/redis/clients/jedis/Jedis.java b/src/main/java/redis/clients/jedis/Jedis.java index ade7c86de8..4a65eebd6c 100644 --- a/src/main/java/redis/clients/jedis/Jedis.java +++ b/src/main/java/redis/clients/jedis/Jedis.java @@ -4566,12 +4566,6 @@ public long xtrim(byte[] key, XTrimParams params) { return connection.executeCommand(commandObjects.xtrim(key, params)); } - @Override - public Object xpending(final byte[] key, final byte[] groupname) { - checkIsInMultiOrPipeline(); - return connection.executeCommand(commandObjects.xpending(key, groupname)); - } - /** * @deprecated Use {@link Jedis#xpending(byte[], byte[], redis.clients.jedis.params.XPendingParams)}. */ @@ -4583,6 +4577,12 @@ public List xpending(byte[] key, byte[] groupname, byte[] start, byte[] return connection.executeCommand(commandObjects.xpending(key, groupname, start, end, count, consumername)); } + @Override + public Object xpending(final byte[] key, final byte[] groupname) { + checkIsInMultiOrPipeline(); + return connection.executeCommand(commandObjects.xpending(key, groupname)); + } + @Override public List xpending(final byte[] key, final byte[] groupname, final XPendingParams params) { checkIsInMultiOrPipeline();