IndexTreeList java.lang.IndexOutOfBoundsException calling addFirst(E e) on an empty list
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 62/100
Research direction
Search for IndexTreeList and its checkIndex(index: Int) method, then trace addFirst(E e) on an empty list. Verify the insertion boundary against the Java add contract, and confirm that addFirst succeeds when size is zero while invalid indexes still fail.
Written by the indexing model from the issue text.
Description
Issue Summary: The method checkIndex(index: Int) in the class IndexTreeList (version 3.1.0) appears to enforce an index boundary check that aligns with the contract for AbstractList.set(index, element), but not with that of add(E e) or addFirst(E e).
Code Reference:
fun checkIndex(index: Int) {
if (index < 0 || index >= size)
throw IndexOutOfBoundsException()
}
According to the Java documentation, the index validation for add(int index, E element) (and by extension for similar insertion methods such as addFirst(E e)) should be:
IndexOutOfBoundsException – if the index is out of range (index < 0 || index > size())
The issue manifests when calling addFirst(E e) on an empty IndexTreeList. Internally, this results in a call to checkIndex(0), which throws IndexOutOfBoundsException, even though 0 is a valid index for insertion into an empty list (where size == 0).
- Dominant language
- Java
- Stars
- 5.1k
- Forks
- 877
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
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 jankotek/mapdb
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
Switch from `org.lz4:lz4-java` to `at.yawk.lz4:lz4-java` due to CVE-2025-12183 & CVE-2025-66566. Open
Difficulty 2/5 1-3 hours Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100