mirror of https://github.com/apache/lucene.git
LUCENE-9147: Make sure temporary files get deleted on all code paths.
This commit is contained in:
parent
7f4560c59a
commit
85dba7356f
|
@ -80,21 +80,15 @@ public final class FieldsIndexWriter implements Closeable {
|
|||
this.blockShift = blockShift;
|
||||
this.ioContext = ioContext;
|
||||
this.docsOut = dir.createTempOutput(name, codecName + "-doc_ids", ioContext);
|
||||
IndexOutput filePointersOut = null;
|
||||
boolean success = false;
|
||||
try {
|
||||
CodecUtil.writeHeader(docsOut, codecName + "Docs", VERSION_CURRENT);
|
||||
this.filePointersOut = filePointersOut = dir.createTempOutput(name, codecName + "file_pointers", ioContext);
|
||||
filePointersOut = dir.createTempOutput(name, codecName + "file_pointers", ioContext);
|
||||
CodecUtil.writeHeader(filePointersOut, codecName + "FilePointers", VERSION_CURRENT);
|
||||
success = true;
|
||||
} finally {
|
||||
if (success == false) {
|
||||
docsOut.close();
|
||||
dir.deleteFile(docsOut.getName());
|
||||
if (filePointersOut != null) {
|
||||
filePointersOut.close();
|
||||
dir.deleteFile(filePointersOut.getName());
|
||||
}
|
||||
close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue