Skip to content

Empty lines after chunk throw UnifiedDiffParserException #225

@MadnessIRL

Description

@MadnessIRL

Description
Empty lines after chunk line seem to crash the UnifiedDiffReader.parseUnifiedDiff() method.

To Reproduce
Steps to reproduce the behavior:

  1. Example data:
index 9e852060c..649690b43 100644
--- a/modules/configuration/gsrc/com/guidewire/pl/docexamples/DMSServlet.gs
+++ b/modules/configuration/gsrc/com/guidewire/pl/docexamples/DMSServlet.gs
@@ -37,6 +37,7 @@ class DMSServlet extends HttpServlet {
 
   public static final var ATTRIB_DOC_PUBLICID_PARAM: String = "Document.PublicID"
   public static final var ATTRIB_JOIN_TABLE_TYPE: String = "JoinTable.Type"
+  //a test
   public static final var ATTRIB_JOIN_TABLE_PROPERTY: String = "JoinTable.JoinedProperty"
   public static final var ATTRIB_JOINED_PUBLICID: String = "Joined.PublicID"
   private var _purgeableUrl: String
diff --git a/testfile.txt b/testfile.txt
new file mode 100644
index 000000000..0ccd05bf0
--- /dev/null
+++ b/testfile.txt
@@ -0,0 +1 @@
+file.test
  1. Run UnifiedDiffReader.parseUnifiedDiff(new ByteArrayInputStream(raw.getBytes(StandardCharsets.UTF_8)));
  2. You will get:
WARNING:   >>> no rule matched 
com.github.difflib.unifieddiff.UnifiedDiffParserException: expected data line not found
	at com.github.difflib.unifieddiff.UnifiedDiffReader.parse(UnifiedDiffReader.java:145)
	at com.github.difflib.unifieddiff.UnifiedDiffReader.parseUnifiedDiff(UnifiedDiffReader.java:205)

because this line is empty:

Image

Expected behavior
Empty lines should not throw errors here according to my understanding.

System

  • Java version 21
  • Version [e.g. 4.15 (latest)]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions