[
https://issues.apache.org/jira/browse/LUCENE-2108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12785563#action_12785563
]
Simon Willnauer commented on LUCENE-2108:
-----------------------------------------
bq. I'd assume ensureOpen needs to be synchronized some way so that two threads
can't open IndexSearchers concurrently?
this class is not threadsafe anyway. If you look at this snippet:
{code}
// close the old searcher, if there was one
if (searcher != null) {
searcher.close();
}
searcher = new IndexSearcher(this.spellIndex, true);
{code}
there could be a race if you concurrently reindex or set a new dictionary. IMO
this should either be documented or made threadsafe. The close method should
invalidate the spellchecker - it should not be possible to use a already closed
Spellchecker.
The searcher should be somehow ref counted so that if there is a searcher still
in use you can concurrently reindex / add a new dictionary to ensure that the
same searcher is used throughout suggestSimilar().
I will take care of it once I get back tomorrow.
> SpellChecker file descriptor leak - no way to close the IndexSearcher used by
> SpellChecker internally
> -----------------------------------------------------------------------------------------------------
>
> Key: LUCENE-2108
> URL: https://issues.apache.org/jira/browse/LUCENE-2108
> Project: Lucene - Java
> Issue Type: Bug
> Components: contrib/spellchecker
> Affects Versions: 3.0
> Reporter: Eirik Bjorsnos
> Assignee: Michael McCandless
> Fix For: 3.0.1, 3.1
>
> Attachments: LUCENE-2108-SpellChecker-close.patch, LUCENE-2108.patch
>
>
> 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 index, 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 if desired.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]