`RedisList.reversed()` view returns an empty `range` and `trim` removes all elements
Maintainers usually reply within 8 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start by locating ReversedRedisListView and its range and trim methods, then read the existing index-based methods to understand how the view maps indexes. Add tests for ranges and trims spanning multiple elements, including a negative end index, and verify the view follows reversed order while preserving the expected underlying list. The issue reports reproduction on Redis 8.6.2 with Lettuce and Jedis.
Written by the indexing model from the issue text.
Description
ReversedRedisListView (returned by RedisList.reversed()) translates range and trim by swapping the two indexes:
public List<E> range(long start, long end) {
return this.base.range(end, start);
}
public RedisList<E> trim(long start, long end) {
this.base.trim(end, start);
return this;
}
For a range spanning more than one element, Redis then receives a start index behind the end index, so range returns an empty list and trim removes every element:
RedisList<String> list = RedisList.create("list", template); // [1, 2, 3, 4]
RedisList<String> reversed = list.reversed(); // [4, 3, 2, 1]
reversed.range(0, 1); // [], expected [4, 3]
reversed.range(0, -1); // [], expected [4, 3, 2, 1]
reversed.trim(0, 1); // removes the key, expected the view to be [4, 3]
Expected: both methods apply to the elements in the order of the view, like get(int) and the other index-based methods do. Redis counts negative indexes from the tail, so the index i of the view is the index -i - 1 of the underlying list. range(start, end) can therefore be served by LRANGE key (-end - 1) (-start - 1) with the result reversed, and trim(start, end) by LTRIM key (-end - 1) (-start - 1).
Reproduced on main against Redis 8.6.2 with Lettuce and Jedis. 3.5.x, 4.0.x and 4.1.x contain the same code. I will submit a PR with a fix and tests.
- Dominant language
- Java
- Stars
- 1.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from spring-projects/spring-data-redis
-
RENAME on cluster connections drops the source key's TTL when keys are in different slotsPossibly taken @mp911de claimed this 6 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
spring-projects/spring-data-redis#3476 · 1 assignee ·
Maintainers usually reply within 8 days
-
PathIndexResolver iterates byte[] element-by-element, causing O(n) overheadPossibly taken @mp911de claimed this 9 days ago. Opentype: bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
spring-projects/spring-data-redis#3460 · 1 assignee ·
Maintainers usually reply within 8 days
-
type: task
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
spring-projects/spring-data-redis#3479 ·
Maintainers usually reply within 8 days
-
type: task
Difficulty 4/5 3-5 days Newbie friendliness 25/100
spring-projects/spring-data-redis#3478 ·
Maintainers usually reply within 8 days
-
type: task
Difficulty 5/5 Over a week Newbie friendliness 20/100
spring-projects/spring-data-redis#3477 ·
Maintainers usually reply within 8 days
All issues in spring-projects/spring-data-redis
Similar issues
-
bug web-server
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
jooby-project/jooby#4035 ·
Maintainers usually reply within 1 day
-
L: javascript
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dependabot/dependabot-core#16744 ·
Maintainers usually reply within 1 day
-
intake mcp-intake needs-human-review priority:high type:bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Ikalus1988/MisakaNet#3987 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
quarkiverse/quarkus-google-cloud-services#1187 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 82/100
locationtech/jts#1250 ·