Index: lucene/CHANGES.txt =================================================================== --- lucene/CHANGES.txt (revision 1529841) +++ lucene/CHANGES.txt (working copy) @@ -103,6 +103,9 @@ 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 Index: lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java (revision 1529841) +++ lucene/core/src/java/org/apache/lucene/index/ReadersAndLiveDocs.java (working copy) @@ -264,9 +264,8 @@ } /** - * 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 Index: lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java =================================================================== --- lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java (revision 1529841) +++ lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java (working copy) @@ -82,10 +82,9 @@ final SegmentInfos segmentInfos = infos.clone(); int infosUpto = 0; - for (int i=0;i