Skip to content

Commit

Permalink
Fix bug when COUNT > Integer.MAX_VALUE (#2431)
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 authored Mar 14, 2021
1 parent b77ed3f commit dbfc929
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ List<GeoRadiusResponse> georadiusByMemberReadonly(byte[] key, byte[] member, dou
*/
@Deprecated
default List<byte[]> 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<byte[]> xrange(byte[] key, byte[] start, byte[] end, int count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ public void xrange() {
StreamEntryID id3 = jedis.xadd("xrange-stream", null, map);
List<StreamEntry> range7 = jedis.xrange("xrange-stream", id2, id2, 4);
assertEquals(1, range7.size());

// count parameter - backward compatibility
List<byte[]> cRange = jedis.xrange("xrange-stream".getBytes(), id1.toString().getBytes(),
id2.toString().getBytes(), 10L + Integer.MAX_VALUE);
assertEquals(2, cRange.size());
}

@Test
Expand Down

0 comments on commit dbfc929

Please sign in to comment.