lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eirik Bjørsnøs <>
Subject Potential leak of file resources in SpellChecker
Date Wed, 02 Dec 2009 17:44:05 GMT

I'm using SpellChecker (in Lucene contrib) to help users of SVNSearch
who can't type right:

SpellChecker works very well for my purpose, but I've encountered a
possible file resource leak issue:

I can't find any way to close the IndexSearcher (and IndexReader) that
is being used by SpellChecker internally.

I've worked around this issue by keeping a single SpellChecker open
for each repository, but I'd really like to be able to close it and
reopen it on demand without leaking file descriptors.

Could we add a close() method to SpellChecker that will close the
IndexSearcher and null the reference to it? And perhaps add some code
that reopens the searcher if the reference to it is null? Or would
that break thread safety of SpellChecker?

The attached patch adds a close method but leaves it to the user to
call setSpellIndex to reopen the searcher.


View raw message