Skip to content

The empty line is ignored #31

Open

Description

@mrdrivingduck

The test case is as follows:

diff --git a/source/org/jfree/data/DefaultKeyedValues.java b/source/org/jfree/data/DefaultKeyedValues.java
index 5569198..707eb0a 100644
--- a/source/org/jfree/data/DefaultKeyedValues.java
+++ b/source/org/jfree/data/DefaultKeyedValues.java
@@ -315,7 +315,9 @@ public class DefaultKeyedValues implements KeyedValues,
     public void removeValue(int index) {
         this.keys.remove(index);
         this.values.remove(index);
+        if (index < this.keys.size()) {
         rebuildIndex();
+        }
     }

     /**
@@ -330,8 +332,7 @@ public class DefaultKeyedValues implements KeyedValues,
     public void removeValue(Comparable key) {
         int index = getIndex(key);
         if (index < 0) {
-            throw new UnknownKeyException("The key (" + key 
-                    + ") is not recognised.");
+			return;
         }
         removeValue(index);
     }

There should be two hunks, but the first hunk ends at line 321, and the second hunk is completely ignored.

Activity

  1. ayeletlevron commented on Mar 27, 2020

    @ayeletlevron

    Funny, I encountered a similar case a few days ago.
    In my case there was another diff starting right after.
    I think this is a bug that happens when you have an empty line inside a hunk's content, and no new line before the next diff. the parser assumes there would be an empty line before the next diff, which is not the case.
    As a workaround, adding an empty line before each new diff helped (append(System.lineSeparator())).

  2. mrdrivingduck commented on Mar 28, 2020

    @mrdrivingduck
    Author

    Funny, I encountered a similar case a few days ago.
    In my case there was another diff starting right after.
    I think this is a bug that happens when you have an empty line inside a hunk's content, and no new line before the next diff. the parser assumes there would be an empty line before the next diff, which is not the case.
    As a workaround, adding an empty line before each new diff helped (append(System.lineSeparator())).

    Yes, you are right. But I have a large data set of diff files so I don't want to modify them, though I have also tried your workaround and it worked. 😅
    I have tried to trace the route cause and I think the route cause is here. I added an additional condition and solved my issue, but I don't know if it is a good solution.

  3. ayeletlevron commented on Mar 29, 2020

    @ayeletlevron

    Yes, I got to the same root cause when I traced the issue. I had to find a workaround without changing the library..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions