DefaultRedisList.get(int) does not reject an index equal to the list size
Maintainers usually reply within 5 days
Assessment
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Newbie friendliness
- 68/100
Research direction
Start with the get(int) method in DefaultRedisList, where the bounds check uses index > size() and should reject index >= size(). Check the linked related PR #3470 first, since it may already contain this fix. Add or run unit tests with mocked BoundListOperations for get(size) and get(0) on an empty list. Done when both throw IndexOutOfBoundsException and the existing valid-index tests still pass.
Written by the indexing model from the issue text.
Description
Description
DefaultRedisList.get(int) does not throw IndexOutOfBoundsException when the index equals the list size, contrary to the List.get(int) contract.
The current bounds check uses index > size() instead of index >= size(). This allows an invalid index to reach the underlying Redis operation.
Example
Given a list containing [A, B, C]:
| Call | Expected result |
|---|---|
get(0) |
A |
get(2) |
C |
get(3) |
IndexOutOfBoundsException |
The same issue occurs when calling get(0) on an empty list.
Steps to reproduce
- Create a
DefaultRedisListcontaining three elements. - Call
get(3). - Observe that the expected
IndexOutOfBoundsExceptionis not thrown.
Alternatively, create an empty list and call get(0).
Expected behavior
get(int) should throw IndexOutOfBoundsException when index < 0 or index >= size().
Actual behavior
An index equal to size() passes the bounds check and is forwarded to BoundListOperations.index(...) without throwing the expected exception.
Verification
Added unit tests using mocked BoundListOperations:
- Reading index
0from an empty list: fails because no exception is thrown. - Reading index
3from a list of size3: fails because no exception is thrown. - Reading index
2from a list of size3: passes.
After changing the upper-bound check to index >= size(), all three tests pass.
Environment
- Spring Data Redis:
4.2.0-SNAPSHOT - Java: 21
Related PR: #3470
- 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
-
`RedisList.reversed()` view returns an empty `range` and `trim` removes all elementsPossibly taken @CCCLL claimed this 2 days ago. Openstatus: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
spring-projects/spring-data-redis#3461 ·
Maintainers usually reply within 5 days
-
PathIndexResolver iterates byte[] element-by-element, causing O(n) overheadPossibly taken @zemiles claimed this 2 days ago. Openstatus: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
spring-projects/spring-data-redis#3460 ·
Maintainers usually reply within 5 days
-
`migrate(…)` ignores `MigrateOption` when using LettucePossibly taken @CCCLL claimed this 1 day ago. Openstatus: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 22/100
spring-projects/spring-data-redis#3467 ·
Maintainers usually reply within 5 days
-
`RedisList.putFirst(…)` adds the element at the tail of the listPossibly taken @CCCLL claimed this 1 day ago. Openstatus: waiting-for-triage
Difficulty 2/5 1-3 hours Newbie friendliness 30/100
spring-projects/spring-data-redis#3464 ·
Maintainers usually reply within 5 days
-
Asynchronous Redis cache writes ignore failed lock acquisition and delete an existing lockPossibly taken @mp911de claimed this 10 days ago. Opentype: bug
Difficulty 4/5 3-5 days Newbie friendliness 25/100
spring-projects/spring-data-redis#3450 · 1 assignee ·
Maintainers usually reply within 5 days
All issues in spring-projects/spring-data-redis
Similar issues
-
area/plugin good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
kestra-io/plugin-soda#137 ·
-
area/plugin good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
kestra-io/plugin-aws#816 ·
Maintainers usually reply within 2 days
-
area/plugin good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
kestra-io/plugin-kestra#200 ·
Maintainers usually reply within 1 day
-
bug untriaged
Difficulty 1/5 Under an hour Newbie friendliness 92/100
opensearch-project/search-relevance#618 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
apache/rocketmq-dashboard#6716 ·
Maintainers usually reply within 3 days