mirror of https://github.com/apache/lucene.git
LUCENE-3661: clean this up to use IOUtils method
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/lucene3661@1233945 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f6b18248a9
commit
52ab0d610e
|
@ -9,6 +9,7 @@ import org.apache.lucene.index.SegmentInfo;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.IOContext;
|
import org.apache.lucene.store.IOContext;
|
||||||
import org.apache.lucene.util.Bits;
|
import org.apache.lucene.util.Bits;
|
||||||
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.MutableBits;
|
import org.apache.lucene.util.MutableBits;
|
||||||
|
|
||||||
public class Lucene40LiveDocsFormat extends LiveDocsFormat {
|
public class Lucene40LiveDocsFormat extends LiveDocsFormat {
|
||||||
|
@ -34,19 +35,14 @@ public class Lucene40LiveDocsFormat extends LiveDocsFormat {
|
||||||
// nocommit: this api is ugly...
|
// nocommit: this api is ugly...
|
||||||
String filename = IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen());
|
String filename = IndexFileNames.fileNameFromGeneration(info.name, DELETES_EXTENSION, info.getDelGen());
|
||||||
|
|
||||||
// nocommit: is it somehow cleaner to still have IW do this try/finally/delete stuff and add abort() instead?
|
// nocommit: test if we really need this
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
((BitVector)bits).write(dir, filename, context);
|
((BitVector)bits).write(dir, filename, context);
|
||||||
success = true;
|
success = true;
|
||||||
} finally {
|
} finally {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
try {
|
IOUtils.deleteFilesIgnoringExceptions(dir, filename);
|
||||||
dir.deleteFile(filename);
|
|
||||||
} catch (Throwable t) {
|
|
||||||
// suppress this so we keep throwing the
|
|
||||||
// original exception
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue