truncate new segment files before use: LUCENE-415

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@415808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yonik Seeley 2006-06-20 21:28:42 +00:00
parent c81983524f
commit 66a23a8786
2 changed files with 11 additions and 0 deletions

View File

@ -48,6 +48,10 @@ Bug fixes
8. LUCENE-607: ParallelReader's TermEnum fails to advance properly to
new fields (Chuck Williams, Christian Kohlschuetter via Yonik Seeley)
9. LUCENE-415: A previously unclean shutdown during indexing can cause
a non-empty segment file to be re-used, causing index corruption.
(Andy Hind via Yonik Seeley)
Optimizations
1. LUCENE-586: TermDocs.skipTo() is now more efficient for multi-segment

View File

@ -496,6 +496,13 @@ class FSIndexOutput extends BufferedIndexOutput {
public FSIndexOutput(File path) throws IOException {
file = new RandomAccessFile(path, "rw");
if (file.length() == 0) {
// This can happen if there was a previous crash / unclean shutdown that
// left files around, then we end up re-using a segment name.
// If we have a logging framework in the future, a warning here might be
// a good idea.
file.setLength(0);
}
}
/** output methods: */