apache / apache/lucene

Fix abusive usage of assert in ArrayUtil [LUCENE-8969]

Open
#10,012 0 comments 0 reactions 0 assignees View on GitHub
legacy-jira-priority:Minor type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Methods in `o.a.l.util.ArrayUtil` uses `assert` statements for argument checks.
It would be suitable to throw \`IllegalArgumentExceptions`s instead of assertions here, to improve traceability when the violations occur? Sometimes I had difficulty in identifying the cause of assertion errors...

---
Migrated from [LUCENE-8969](https://issues.apache.org/jira/browse/LUCENE-8969) by Tomoko Uchida (@mocobeta)

Contributor guide

Open the contributing guide

Research direction

Locate o.a.l.util.ArrayUtil and review the methods that use assert statements for argument checks. Replace those checks with IllegalArgumentExceptions, then verify that invalid arguments consistently produce the intended exceptions and that the relevant tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.