Skip to content

ArrayIndexOutOfBounds exception when the text includes a line that matches the format "@@ -2,6 +2,7 @@" #19

@GoogleCodeExporter

Description

@GoogleCodeExporter
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.


Original issue reported on code.google.com by meena...@gmail.com on 5 Jun 2011 at 10:10

Attachments:

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions