Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 7211 invoked from network); 26 Feb 2007 20:22:29 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 26 Feb 2007 20:22:29 -0000 Received: (qmail 86222 invoked by uid 500); 26 Feb 2007 20:22:35 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 86187 invoked by uid 500); 26 Feb 2007 20:22:35 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 86176 invoked by uid 99); 26 Feb 2007 20:22:35 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Feb 2007 12:22:34 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 26 Feb 2007 12:22:25 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 988A571403E for ; Mon, 26 Feb 2007 12:22:05 -0800 (PST) Message-ID: <15669560.1172521325622.JavaMail.jira@brutus> Date: Mon, 26 Feb 2007 12:22:05 -0800 (PST) From: "Doron Cohen (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Commented: (LUCENE-818) IndexWriter should detect when it's used after being closed In-Reply-To: <31514116.1172518447790.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/LUCENE-818?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475987 ] Doron Cohen commented on LUCENE-818: ------------------------------------ I looked at Java IO as a reference for acceptable behavior in this regard. If you close a file system object and try to use it, - RandomAccessFile will throw IOException with: "No such file or directory" - FileWriter will throw IOException with "Stream closed" - FileOutputStream will throw IOException with "Stream closed" So you could say that Java did not go all the way with a well defined illegalState exception. Databases on the other hand would give you a well definied error code. I don't have a strong opinion if this is a must for Lucene or not. But if this is to be added, one way to do it is to define a Closable interface { close(); isOpen() }, implement this interface in all public classes that need to check open state (IndexWriter, IndexReader, etc.), add a single static ensureOpen(Closable) method in a utils class that would throw the IllegalState exception, and just call this method from every (public?) open-state open dependent method. I think this would keep the 'noise' in the code to minimum. > 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 > > 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