lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: Is it safe to use reopen on IndexReader
Date Wed, 31 Mar 2010 14:43:02 GMT
It's perfectly safe to .reopen a reader when other threads are using
that reader (eg, for searching, or for anything else).  The reopen
call doesn't affect the original reader in any way.

You should close the old reader when you're done (if indeed a new
reader was returned by .reopen), but if multiple threads may be using
it, you should use incRef/decRef to make sure the close only happens
when all threads are done.

That if check is necessary -- if the reader is unchanged (not
reopened) you shouldn't close the old one.


On Wed, Mar 31, 2010 at 8:36 AM, Jason Tesser <> wrote:
> Is it safe to use reopen on IndexReader if their are other threads who had
> readers out or do I need to use a ref counter to make sure all readers are
> checked in?
> Secondly right now we also check this when we reopen
> IndexReader ir = indexSearcher.getIndexReader();
>                    indexSearcher = new IndexSearcher(ir.reopen(true));
>                    if(ir != indexSearcher.getIndexReader()){
>                        ir.close();
>                    }
> Is the if(ir != indexSearcher.getIndexReader()){   check needed?
> Thanks,
> Jason Tesser
> dotCMS Lead Development Manager
> 1-305-858-1422

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message