What steps will reproduce the problem?
1. Add a line as below to the revised text.
@@ -2,6 +2,7 @@
2. Generate unified diff text.
3. Now create a 'Patch' from above diff text using DiffUtils.parseUnifiedText().
4. The following will be thrown.
Caused by: java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.RangeCheck(ArrayList.java:547)
at java.util.ArrayList.get(ArrayList.java:322)
at com.difflib.textdiff.difflib.Chunk.verify(Chunk.java:92)
at com.difflib.textdiff.difflib.ChangeDelta.verify(ChangeDelta.java:91)
at com.difflib.textdiff.difflib.ChangeDelta.applyTo(ChangeDelta.java:41)
at com.difflib.textdiff.difflib.Patch.applyTo(Patch.java:47)
at com.difflib.textdiff.TextDiffGenerator.applyDiff(TextDiffGenerator.java:113)
... 23 more
Attached the updated file DiffUtils.java with a fix. A flag to prevent the
processing of header line after the first time seems to fix the issue.