On 03/11/2011 15:57, Paul Taylor wrote:
Been looking at the SearcherManager code to fix my code so that it doesn't close an IndexReader whilst still being used , but everytime I look at the SearchManager code it appears it will never close it, am I misunderstaning something or is there a typo

This is how I see it

When an IndexSearcher from a reader is created getRef() returns 1
So a subsequent call to close for indexSearcher.getIndexReader() would reduce ref to zero and it would close.

In the SearchServer code, the ref count is increase on every usage via get() and decreased once finished with using release(). BUT the maybeReopen() method also calls get(), so even if the reader wasn't being used it refcount() would then be 2 and the so the call to release() within maybeReopen() will only take it down to one not zero, and hence it will never actually be closed ?

Paul

Oh hangon, I missed the fact that swapSearcher also calls release() on the current server, so that would reduce 2 back down to 1 , and then doneReopen() takes it down to zero.

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to