Skip to content

Commit

Permalink
Merge pull request #31643 from cescoffier/redis-sorted-set-empty-rang…
Browse files Browse the repository at this point in the history
…e-bug

Fix iterator issue when executing a zrange with score on a missing key
  • Loading branch information
gsmet authored Mar 7, 2023
2 parents de60978 + 048c4a9 commit 89575ea
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ protected String getScoreAsString(double score) {

final List<ScoredValue<V>> decodeAsListOfScoredValues(Response response) {
List<ScoredValue<V>> list = new ArrayList<>();
if (!response.iterator().hasNext()) {
return Collections.emptyList();
}
if (response.iterator().next().type() == ResponseType.BULK) {
// Redis 5
V current = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ void zrevrange() {
.isEqualTo(List.of(Place.suze, Place.grignan, Place.crussol));
}

@Test
@RequiresRedis6OrHigher
void zrevrangeWithScoreEmpty() {
assertThat(ds.sortedSet(String.class).zrangeWithScores("top-products", 0, 2, new ZRangeArgs().rev())).isEmpty();
}

@Test
@RequiresRedis6OrHigher
void zrevrangeWithScores() {
Expand Down

0 comments on commit 89575ea

Please sign in to comment.