lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-818) IndexWriter should detect when it's used after being closed
Date Tue, 06 Mar 2007 21:21:25 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12478585
] 

Michael McCandless commented on LUCENE-818:
-------------------------------------------


> i would make sure to *heavily* document each and every use of isOpen/ensureOpen to make
it clear why they are being used when they are from a performance concern case ... otherwise
people will be very confused down the road ("why the hell isn't this being checked until the
catch block?!?!?!")

OK I changed my mind.

I don't think we should add the "check if closed after the fact"
logic.  I reviewed the 4 methods in question (maxDoc, numDocs,
hasDeletions, isDeleted) and for all subclasses of IndexReader these
are very trivial methods that won't throw exceptions.

So I'm back to thinking this added complexity (and future confusion to
people looking @ Lucene source code) isn't worthwhile and we should
leave these methods with no checking for whether they are already
closed.

But I will document why ensureOpen is *not* being called in each of
these methods.

> IndexWriter should detect when it's used after being closed
> -----------------------------------------------------------
>
>                 Key: LUCENE-818
>                 URL: https://issues.apache.org/jira/browse/LUCENE-818
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.1
>            Reporter: Michael McCandless
>         Assigned To: Michael McCandless
>            Priority: Minor
>         Attachments: LUCENE-818.patch, LUCENE-818.take2.patch, LUCENE-818.take3.patch
>
>
> Spinoff from this thread on java-user:
>     http://www.gossamer-threads.com/lists/lucene/java-user/45986
> If you call addDocument on IndexWriter after it's closed you'll hit a
> hard-to-explain NullPointerException (because the RAMDirectory was
> closed).  Before 2.1, apparently you won't hit any exception and the
> IndexWrite will keep running but will have released it's write lock (I
> think).
> I plan to fix IndexWriter methods to throw an IllegalStateException if
> it has been closed.

-- 
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: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message