[ https://issues.apache.org/jira/browse/LUCENE-818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12477875 ]
Hoss Man commented on LUCENE-818: --------------------------------- I havne't been following this issue that closely, and i haven't read any of the patches, but if the goal is: "reduce situations where novice users get confusing exceptions when using IndexWriter after closing it" ...and the concern is that calling a new "ensureOpen()" method at the begining of every public method may be a performacne issue, then perhaps an alternative would be to catch all exceptions inside public methods and wrap them if not closed, ie... public Foo somePublicMethod() throws IOException { try { // current method body } catch (Exception e) { if (isOpen()) { throw e; } else { throw new AllreadyClosedException(e); } } } ...that way any performance cost of ensureOpen/isOpen is only payed on an existing Exception. the down side i see to this approach is that since it only explains exceptions hte caller would get anyway, it doesn't give any feedback about using a closed writer in cases where the current code returns cleanly (but may not function properly) ... we might be able to solve that by adding better error checking in those specific cases (if we know of any) and throwing explicit exceptions. > 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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]