lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <>
Subject Is close() correct?
Date Thu, 25 Jun 2009 19:09:32 GMT
Are the semantics of close() really correct when reopen() is used?

  public final synchronized void close() throws IOException {
    if (!closed) {
      closed = true;

Solr has the following code:
        IndexReader newReader = currentReader.reopen();
        if (newReader == currentReader) {

reopen() used to return the same instance if no changes had been made
- that makes sense.
But then of you do a close on both the currentReader and newReader,
only one decRef() will be called!

The reopen() javadoc suggests this has not changed:
   * If the index has not changed since this instance was (re)opened, then this
   * call is a NOOP and returns this instance.

Seems like the "closed" variable just be eliminated completely?
Throwing an exception on too many closes (rather than silently
ignoring) would probably be doing people a favor.


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

View raw message