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
aa916bac3c
commit
6a380798a2
|
@ -80,21 +80,15 @@ public final class FieldsIndexWriter implements Closeable {
|
||||||
this.blockShift = blockShift;
|
this.blockShift = blockShift;
|
||||||
this.ioContext = ioContext;
|
this.ioContext = ioContext;
|
||||||
this.docsOut = dir.createTempOutput(name, codecName + "-doc_ids", ioContext);
|
this.docsOut = dir.createTempOutput(name, codecName + "-doc_ids", ioContext);
|
||||||
IndexOutput filePointersOut = null;
|
|
||||||
boolean success = false;
|
boolean success = false;
|
||||||
try {
|
try {
|
||||||
CodecUtil.writeHeader(docsOut, codecName + "Docs", VERSION_CURRENT);
|
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);
|
CodecUtil.writeHeader(filePointersOut, codecName + "FilePointers", VERSION_CURRENT);
|
||||||
success = true;
|
success = true;
|
||||||
} finally {
|
} finally {
|
||||||
if (success == false) {
|
if (success == false) {
|
||||||
docsOut.close();
|
close();
|
||||||
dir.deleteFile(docsOut.getName());
|
|
||||||
if (filePointersOut != null) {
|
|
||||||
filePointersOut.close();
|
|
||||||
dir.deleteFile(filePointersOut.getName());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue