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

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

Yes, this is about giving a clear (and prompt) error message when
Lucene is used incorrectly.

LUCENE-140 was also a similar situation.  In that case incorrect usage
could lead to index corruption much later.

I feel like that is important because it affects the perceived quality
of Lucene.  Enough users seem to hit this (especially common seems to
be iterating through Hits after the reader is closed).  As Lucene
adoption grows, more users will hit it.

Because detection of this now is so "intermittant" (undefined), a
developer could think everything is OK in testing, push things into
their production world, only to suddenly see an error.  Then, the
error is something strange (eg confusing NullPointerException) which
doesn't make it clear what's happened.

In the IndexWriter case it's potentially devastating because (I
think?) if you keep using your closed IndexWriter, then, it's
operating on the index without holding the write lock (this was pre
2.1).

I do agree we shouldn't go overboard with this (eg I certainly think
we should not add checks inside things like TermDocs/TermPositions).

And I agree this is in general a difficult tradeoff.

But I think in this case the performance impact is likely very small; I could
work out a test to be sure.

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


> 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
>
>
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to