lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael McCandless (JIRA)" <>
Subject [jira] Commented: (LUCENE-818) IndexWriter should detect when it's used after being closed
Date Mon, 26 Feb 2007 23:55:05 GMT


Michael McCandless commented on LUCENE-818:

That approach seems a little overkill to me.

I would need to create a new Closeable interface, and then a static
"ensureOpen" method somewhere else.  These would probably live in
util, so then this is all public: users see that these classes
implement Closeable, yet, it's not really a publicly useful feature,
so it adds noise to the javadocs.

I was planning instead on just adding a private "ensureOpen()" to
IndexWriter (and I agree I should do IndexReader as well) that throws
IllegalStateException if it's closed.  I think noise is kept to the
same minimum (?) because all public methods that require this just have an
added ensureOpen() call at the top.  This is how IndexModifier works

Hmm, IndexReader already throws IOException in certain cases if it's
already closed.  So I think I will make a new exception
(AlreadyClosedException?) that subclasses IOException and throw that.

> IndexWriter should detect when it's used after being closed
> -----------------------------------------------------------
>                 Key: LUCENE-818
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Index
>    Affects Versions: 2.1
>            Reporter: Michael McCandless
>         Assigned To: Michael McCandless
>            Priority: Minor
> Spinoff from this thread on java-user:
> 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:
For additional commands, e-mail:

View raw message