albfan / jmeld

A visual diff and merge tool
44 stars 31 forks source link

java.nio.BufferOverflowException #47

Closed WolfgangFahl closed 6 years ago

WolfgangFahl commented 6 years ago

java.nio.BufferOverflowException at java.nio.CharBuffer.put(CharBuffer.java:922) at java.nio.CharBuffer.put(CharBuffer.java:950) at org.jmeld.diff.JMDiff.filter(JMDiff.java:249) at org.jmeld.diff.JMDiff.diff(JMDiff.java:110) at org.jmeld.util.node.JMDiffNode.diff(JMDiffNode.java:294) at org.jmeld.ui.FileComparison.doInBackground(FileComparison.java:94) at org.jmeld.ui.FileComparison.doInBackground(FileComparison.java:17)

WolfgangFahl commented 6 years ago

Please find below the fix by increasing the buffer size and which is more important making it configurable ...

public class JMDiff
 {
+  public static int BUFFER_SIZE=100000;
   // Class variables:
   // Allocate a charBuffer once for performance. The charbuffer is used to
   //   store a 'line' without it's ignored characters. 
-  static final private CharBuffer inputLine = CharBuffer.allocate(10000);
-  static final private CharBuffer outputLine = CharBuffer.allocate(10000);
+  static final private CharBuffer inputLine = CharBuffer.allocate(BUFFER_SIZE);
+  static final private CharBuffer outputLine = CharBuffer.allocate(BUFFER_SIZE)
WolfgangFahl commented 6 years ago

Would you please release a new version to maven to make this fix available ...

albfan commented 6 years ago

Thanks for working on these. This bug is really a stopper to use jmeld.

Can you provide a PR so I can merge?

WolfgangFahl commented 6 years ago

Hi albfan - i am having trouble getting my old fork in sync - when I tried to push it tried to do it against the master where I do not have access. Since it's ownly three lines of code I'd appreciate if you use the diff above.

albfan commented 6 years ago

Sure, no problem

albfan commented 6 years ago

Fixed on 44cd1ca