From dbfc9299b1eeabf75c0f4b4b151413cd77338105 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Sun, 14 Mar 2021 16:59:21 +0600 Subject: [PATCH] Fix bug when COUNT > Integer.MAX_VALUE (#2431) --- .../redis/clients/jedis/commands/BinaryJedisCommands.java | 2 +- .../clients/jedis/tests/commands/StreamsCommandsTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/redis/clients/jedis/commands/BinaryJedisCommands.java b/src/main/java/redis/clients/jedis/commands/BinaryJedisCommands.java index 3df3e6b3a6..b02ff51925 100644 --- a/src/main/java/redis/clients/jedis/commands/BinaryJedisCommands.java +++ b/src/main/java/redis/clients/jedis/commands/BinaryJedisCommands.java @@ -407,7 +407,7 @@ List georadiusByMemberReadonly(byte[] key, byte[] member, dou */ @Deprecated default List xrange(byte[] key, byte[] start, byte[] end, long count) { - return xrange(key, start, end, (int) Math.max(count, (long) Integer.MAX_VALUE)); + return xrange(key, start, end, (int) Math.min(count, (long) Integer.MAX_VALUE)); } List xrange(byte[] key, byte[] start, byte[] end, int count); diff --git a/src/test/java/redis/clients/jedis/tests/commands/StreamsCommandsTest.java b/src/test/java/redis/clients/jedis/tests/commands/StreamsCommandsTest.java index 6e5f6ecf1d..dff33b832c 100644 --- a/src/test/java/redis/clients/jedis/tests/commands/StreamsCommandsTest.java +++ b/src/test/java/redis/clients/jedis/tests/commands/StreamsCommandsTest.java @@ -140,6 +140,11 @@ public void xrange() { StreamEntryID id3 = jedis.xadd("xrange-stream", null, map); List range7 = jedis.xrange("xrange-stream", id2, id2, 4); assertEquals(1, range7.size()); + + // count parameter - backward compatibility + List cRange = jedis.xrange("xrange-stream".getBytes(), id1.toString().getBytes(), + id2.toString().getBytes(), 10L + Integer.MAX_VALUE); + assertEquals(2, cRange.size()); } @Test