UnifiedDiffUtils.getRowMap throws ArrayIndexOutOfBoundsException for hunk headers without a count · Issue #248 · java-diff-utils/java-diff-utils
Repository navigation
UnifiedDiffUtils.getRowMap throws ArrayIndexOutOfBoundsException for hunk headers without a count #248
New issue
New issue
Backlog
#251
Backlog
UnifiedDiffUtils.getRowMap throws ArrayIndexOutOfBoundsException for hunk headers without a count #248 #251
Description
@Prabhav-dev's profile Prabhav-dev opened on Dec 2, 2026Hi,
While testing UnifiedDiffUtils.getRowMap, I noticed that it throws an ArrayIndexOutOfBoundsException when a hunk header omits the range count.
The unified diff format allows the count to be omitted when it is 1. For example:
@@ -1 +1 @@
In this case, org.split(",") returns only one element, but the code still tries to access orgSp[1], resulting in:
java.lang.ArrayIndexOutOfBoundsException:
Index 1 out of bounds for length 1
I think the count should default to 1 when it is omitted.
I'm happy to help with a fix or submit a PR if that's useful.
Thanks!