Close Lucene indices after use to avoid too many open files error
authorJan Lahoda <jlahoda@netbeans.org>
Fri, 25 Feb 2011 19:39:47 +0100
changeset 5514e37e4d972ba
parent 549 c0ac67a767d4
child 552 e0855a9f6040
Close Lucene indices after use to avoid too many open files error
api/src/org/netbeans/modules/jackpot30/impl/indexing/AbstractLuceneIndex.java
     1.1 --- a/api/src/org/netbeans/modules/jackpot30/impl/indexing/AbstractLuceneIndex.java	Tue Feb 15 20:16:07 2011 +0100
     1.2 +++ b/api/src/org/netbeans/modules/jackpot30/impl/indexing/AbstractLuceneIndex.java	Fri Feb 25 19:39:47 2011 +0100
     1.3 @@ -133,8 +133,9 @@
     1.4  
     1.5          if (reader == null) {
     1.6               return Collections.emptyMap();
     1.7 -         }
     1.8 +        }
     1.9  
    1.10 +        try {
    1.11          Searcher s = new IndexSearcher(reader);
    1.12          BitSet matchingDocuments = new BitSet(reader.maxDoc());
    1.13          Collector c = new BitSetCollector(matchingDocuments);
    1.14 @@ -182,6 +183,10 @@
    1.15          }
    1.16  
    1.17          return result;
    1.18 +        } finally {
    1.19 +            //TODO: might be better to cache the index/reader(s)
    1.20 +            reader.close();
    1.21 +        }
    1.22      }
    1.23  
    1.24      private Query query(BulkPattern pattern) throws ParseException {