diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt index d33f857320f..6f668c9e72b 100644 --- a/lucene/CHANGES.txt +++ b/lucene/CHANGES.txt @@ -103,6 +103,9 @@ Bug Fixes to a new reader and closing the original one. (Shai Erera, Mike McCandless) +* LUCENE-5262: Fixed file handle leaks when multiple attempts to open an + NRT reader hit exceptions. (Shai Erera) + API Changes: * LUCENE-5222: Add SortField.needsScores(). Previously it was not possible diff --git a/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java b/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java index 4f01df42aac..f3c8a7e4348 100644 --- a/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java +++ b/lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java @@ -264,9 +264,8 @@ class ReadersAndLiveDocs { // TODO (DVU_RENAME) to ReaderAndUpdates } /** - * Returns a ref to a clone. NOTE: this clone is not - * enrolled in the pool, so you should simply close() - * it when you're done (ie, do not call release()). + * Returns a ref to a clone. NOTE: you should decRef() the reader when you're + * dont (ie do not call close()). */ public synchronized SegmentReader getReadOnlyClone(IOContext context) throws IOException { getReader(true, context).decRef(); // make sure we enroll a new reader if there are field updates diff --git a/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java b/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java index 710a49cc5b0..c187649071a 100644 --- a/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java +++ b/lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java @@ -82,10 +82,9 @@ final class StandardDirectoryReader extends DirectoryReader { final SegmentInfos segmentInfos = infos.clone(); int infosUpto = 0; - for (int i=0;i