Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The empty line is ignored #31

Open
mrdrivingduck opened this issue Mar 26, 2020 · 3 comments
Open

The empty line is ignored #31

mrdrivingduck opened this issue Mar 26, 2020 · 3 comments

Comments

@mrdrivingduck
Copy link

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.

@ayeletlevron
Copy link

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())).

@mrdrivingduck
Copy link
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.

@ayeletlevron
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants