Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 58256 invoked from network); 30 Aug 2006 15:19:55 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Aug 2006 15:19:55 -0000 Received: (qmail 53011 invoked by uid 500); 30 Aug 2006 15:19:54 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 52379 invoked by uid 500); 30 Aug 2006 15:19:52 -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 52368 invoked by uid 99); 30 Aug 2006 15:19:52 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2006 08:19:52 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [194.44.23.182] (HELO mail.spline-software.com) (194.44.23.182) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2006 08:19:51 -0700 Received: by mail.spline-software.com (Postfix, from userid 12) id 40498298762; Wed, 30 Aug 2006 18:18:15 +0300 (EEST) Received: from [192.168.0.86] (vbychkoviak.jforce [192.168.0.86]) by mail.spline-software.com (Postfix) with ESMTP id CF75C2984D8 for ; Wed, 30 Aug 2006 18:16:44 +0300 (EEST) Message-ID: <44F5ABDC.7020101@i-hypergrid.com> Date: Wed, 30 Aug 2006 18:16:44 +0300 From: Volodymyr Bychkoviak User-Agent: Thunderbird 1.5.0.5 (Windows/20060719) MIME-Version: 1.0 To: java-dev@lucene.apache.org Subject: MultiReader.isCurrent() wrong behavior Content-Type: multipart/alternative; boundary="------------050406010001070003060806" X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on spline.jforce X-Spam-Level: X-Virus-Checked: Checked by ClamAV on apache.org X-Old-Spam-Status: No, score=-5.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, HTML_20_30,HTML_MESSAGE autolearn=ham version=3.0.4 X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N --------------050406010001070003060806 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit if MultiReader is constructed from array of subreaders (using publis constructor) then calling isCurrent() method will throw NullPointerException. Testcase is attached below: //-begin -----TestMultiReaderIsCurrent.java ---------- package org.apache.lucene.index; import java.io.IOException; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Field.Index; import org.apache.lucene.document.Field.Store; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import junit.framework.TestCase; public class TestMultiReaderIsCurrent extends TestCase { private Directory dir1 = new RAMDirectory(); private Directory dir2 = new RAMDirectory(); public void testIsCurrent() throws IOException { addDocument(dir1, "test1", true); addDocument(dir2, "test2", true); IndexReader ir1 = IndexReader.open(dir1); IndexReader ir2 = IndexReader.open(dir2); IndexReader mr = new MultiReader(new IndexReader[] {ir1, ir2}); assertTrue("should be true", ir1.isCurrent()); assertTrue("should be true", ir2.isCurrent()); try { assertTrue("should be true", mr.isCurrent()); } catch (RuntimeException e) { fail("no exception should be thrown: " + e.toString()); } addDocument(dir1, "test3", false); assertFalse("should be false", ir1.isCurrent()); assertTrue("should be true", ir2.isCurrent()); try { assertFalse("should false", mr.isCurrent()); } catch (RuntimeException e) { fail("no exception should be thrown: " + e.toString()); } } private void addDocument(Directory dir12, String string, boolean create) throws IOException { IndexWriter iw = new IndexWriter(dir12, new StandardAnalyzer(), create); Document document = new Document(); document.add(new Field("data", string, Store.YES, Index.TOKENIZED)); iw.addDocument(document); iw.close(); } } //-end -----TestMultiReaderIsCurrent.java ---------- -- regards, Volodymyr Bychkoviak --------------050406010001070003060806--