mirror of
https://github.com/apache/lucene.git
synced 2025-03-06 08:19:23 +00:00
Patch for LUCENE-511.
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@382499 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7dab9545be
commit
4b6426ac56
@ -58,6 +58,7 @@ public abstract class BufferedIndexOutput extends IndexOutput {
|
||||
flush();
|
||||
// and write data at once
|
||||
flushBuffer(b, length);
|
||||
bufferStart += length;
|
||||
} else {
|
||||
// we fill/flush the buffer (until the input is written)
|
||||
int pos = 0; // position in the input data
|
||||
|
@ -622,4 +622,26 @@ public class TestCompoundFile extends TestCase
|
||||
is.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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user