Skip to content

Apache Lucene open-source search software

LUCENE-750: fix one case that was not closing an IndexOutput with a try/finally

Michael McCandless19ba76b0d449
diff --git a/src/java/org/apache/lucene/index/SegmentInfos.java b/src/java/org/apache/lucene/index/SegmentInfos.java
index bebb83df9af..1efe8ce4fa3 100644
--- a/src/java/org/apache/lucene/index/SegmentInfos.java
+++ b/src/java/org/apache/lucene/index/SegmentInfos.java
@@ -260,10 +260,13 @@ public final class SegmentInfos extends Vector {
try {
output = directory.createOutput(IndexFileNames.SEGMENTS_GEN);
- output.writeInt(FORMAT_LOCKLESS);
- output.writeLong(generation);
- output.writeLong(generation);
- output.close();
+ try {
+ output.writeInt(FORMAT_LOCKLESS);
+ output.writeLong(generation);
+ output.writeLong(generation);
+ } finally {
+ output.close();
+ }
} catch (IOException e) {
// It's OK if we fail to write this file since it's
// used only as one of the retry fallbacks.