Apache Lucene open-source search software
Patch for LUCENE-511.
Doug Cutting4b6426ac5661
diff --git a/src/java/org/apache/lucene/store/BufferedIndexOutput.java b/src/java/org/apache/lucene/store/BufferedIndexOutput.javaindex d4afe1d3fb0..46bdda0af12 100644--- a/src/java/org/apache/lucene/store/BufferedIndexOutput.java+++ b/src/java/org/apache/lucene/store/BufferedIndexOutput.java@@ -58,6 +58,7 @@ public abstract class BufferedIndexOutput extends IndexOutput {flush();// and write data at onceflushBuffer(b, length);+ bufferStart += length;} else {// we fill/flush the buffer (until the input is written)int pos = 0; // position in the input datadiff --git a/src/test/org/apache/lucene/index/TestCompoundFile.java b/src/test/org/apache/lucene/index/TestCompoundFile.javaindex 17e6f3d0b6f..ae4e7a345aa 100644--- a/src/test/org/apache/lucene/index/TestCompoundFile.java+++ b/src/test/org/apache/lucene/index/TestCompoundFile.java@@ -622,4 +622,26 @@ public class TestCompoundFile extends TestCaseis.close();cr.close();}++ /** This test that writes larger than the size of the buffer output+ * will correctly increment the file pointer.+ */+ public void testLargeWrites() throws IOException {+ IndexOutput os = dir.createOutput("testBufferStart.txt");++ byte[] largeBuf = new byte[2048];+ for (int i=0; i<largeBuf.length; i++) {+ largeBuf[i] = (byte) (Math.random() * 256);+ }++ long currentPos = os.getFilePointer();+ os.writeBytes(largeBuf, largeBuf.length);++ try {+ assertEquals(currentPos + largeBuf.length, os.getFilePointer());+ } finally {+ os.close();+ }++ }}