Skip to content

Apache Lucene open-source search software

LUCENE-6825: make sure we close open file on exception

Michael McCandlessaad653fda5d6
diff --git a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
index 2a74faf5dbf..38a22a28522 100644
--- a/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
+++ b/lucene/core/src/java/org/apache/lucene/util/bkd/BKDWriter.java
@@ -178,6 +178,7 @@ public final class BKDWriter implements Closeable {
// For each .add we just append to this input file, then in .finish we sort this input and resursively build the tree:
offlinePointWriter = new OfflinePointWriter(tempDir, tempFileNamePrefix, packedBytesLength);
+ tempInput = offlinePointWriter.out;
PointReader reader = heapPointWriter.getReader(0);
for(int i=0;i<pointCount;i++) {
boolean hasNext = reader.next();
@@ -186,7 +187,6 @@ public final class BKDWriter implements Closeable {
}
heapPointWriter = null;
- tempInput = offlinePointWriter.out;
}
public void add(byte[] packedValue, int docID) throws IOException {