lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley (JIRA)" <>
Subject [jira] Commented: (LUCENE-818) IndexWriter should detect when it's used after being closed
Date Fri, 02 Mar 2007 21:35:51 GMT


Yonik Seeley commented on LUCENE-818:

> Then, the error is something strange (eg confusing NullPointerException) which doesn't
make it clear what's happened. 

I think that depends on context.  Many cases of NPEs are perfectly clear when you look at
the stack trace.

> In the IndexWriter case it's potentially devastating

Agreed... when it affects correctness, we should fix.

Adding ensureOpen() to something like maxDoc() does not ensure correctness though - an exception
may or may not be thrown in the reader is already closed (because of those thread-safety issues).
 It actually increases the variability of behavior.  We need to be careful not to guarantee
the throwing of the exception.

> especially common seems to be iterating through Hits after the reader is closed

Good point, for document() esp.  I'm OK with the heavyweight methods.

> Maybe we could remove checking for clearly frequently called methods (eg isDeleted)?

That's one of the ones I had in mind... isDeleted() can be called millions of times for a
single query.  Probably numDoc(), maxDoc(), etc, are also candidates.

Earlier detection of bugs when the cost is nil is good though...
what about setting more things to null when a reader is closed?

> 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
>         Attachments: LUCENE-818.patch, LUCENE-818.take2.patch
> 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