Skip to content

Handle empty input in Distances - #92

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-crash-for-empty-distances-input
Closed

Handle empty input in Distances#92
krotname wants to merge 1 commit into
mainfrom
codex/fix-crash-for-empty-distances-input

Conversation

@krotname

@krotname krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Fix a regression where Distances.solve() crashed with ArrayIndexOutOfBoundsException for an empty input array (n == 0) due to the sentinel-based backward scan starting at index 0.

Description

  • Return the empty dist early in Distances.solve() with if (n == 0) return dist; and add an empty-array assertion assertEq(new int[]{}, solve(new int[]{}), "empty"); to the class's built-in tests in src/main/java/algorithms/sprint1/Distances.java to prevent the regression while preserving existing logic.

Testing

  • Ran the full test suite with mvn test (all tests passed: 597 tests, build SUCCESS) and executed the class-level test() check via java -Dos.name=Windows -cp target/classes algorithms.sprint1.Distances which printed OK.

Codex Task

@krotname

krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Superseded by the validated combined merge in #115: #115

@krotname krotname closed this Aug 1, 2026
@krotname
krotname deleted the codex/fix-crash-for-empty-distances-input branch August 1, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant