diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LineReader.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LineReader.java index 153953d2736..e20a7c1084e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LineReader.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/LineReader.java @@ -318,7 +318,10 @@ public class LineReader implements Closeable { break; } } else if (delPosn != 0) { - bufferPosn--; + bufferPosn -= delPosn; + if(bufferPosn < -1) { + bufferPosn = -1; + } delPosn = 0; } } diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLineReader.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLineReader.java index 9d909bcebd0..52f8b9f6ef2 100644 --- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLineReader.java +++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestLineReader.java @@ -58,7 +58,7 @@ public class TestLineReader { * Check Condition * In the second key value pair, the value should contain * "" from next token + * "id>" from next token */ Delimiter=""; @@ -80,20 +80,21 @@ public class TestLineReader { String TestPartOfInput = CurrentBufferTailToken+NextBufferHeadToken; int BufferSize=64 * 1024; - int numberOfCharToFillTheBuffer=BufferSize-CurrentBufferTailToken.length(); + int numberOfCharToFillTheBuffer = + BufferSize - CurrentBufferTailToken.length(); StringBuilder fillerString=new StringBuilder(); - for (int i=0;i