Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 85293 invoked from network); 5 Apr 2010 19:32:50 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Apr 2010 19:32:50 -0000 Received: (qmail 28880 invoked by uid 500); 5 Apr 2010 19:32:49 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 28844 invoked by uid 500); 5 Apr 2010 19:32:49 -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 28837 invoked by uid 99); 5 Apr 2010 19:32:49 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Apr 2010 19:32:49 +0000 X-ASF-Spam-Status: No, hits=-1219.6 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 05 Apr 2010 19:32:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 78A69234C48D for ; Mon, 5 Apr 2010 19:32:28 +0000 (UTC) Message-ID: <1668822839.695171270495948493.JavaMail.jira@brutus.apache.org> Date: Mon, 5 Apr 2010 19:32:28 +0000 (UTC) From: "Michael McCandless (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Resolved: (LUCENE-2365) Finding Newest Segment In Empty Index In-Reply-To: <1080329697.682181270439127213.JavaMail.jira@brutus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LUCENE-2365?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Michael McCandless resolved LUCENE-2365. ---------------------------------------- Resolution: Fixed Fix Version/s: (was: 3.0.1) 3.1 Thanks Karthick! > Finding Newest Segment In Empty Index > ------------------------------------- > > Key: LUCENE-2365 > URL: https://issues.apache.org/jira/browse/LUCENE-2365 > Project: Lucene - Java > Issue Type: Bug > Components: Index > Affects Versions: 3.0.1 > Reporter: Karthick Sankarachary > Assignee: Michael McCandless > Priority: Minor > Fix For: 3.1 > > Attachments: LUCENE-2365.patch > > > While extending the index writer, I discovered that its newestSegment method does not check to see if there are any segments before accessing the segment infos vector. Specifically, if you call the IndexWriter#newestSegment method on a brand-new index which is essentially empty, then it throws an java.lang.ArrayIndexOutOfBoundsException exception. > The proposed fix is to return null if no segments exist, as shown below: > --- lucene/src/java/org/apache/lucene/index/IndexWriter.java (revision 930788) > +++ lucene/src/java/org/apache/lucene/index/IndexWriter.java (working copy) > @@ -4587,7 +4587,7 @@ > > // utility routines for tests > SegmentInfo newestSegment() { > - return segmentInfos.info(segmentInfos.size()-1); > + return segmentInfos.size() > 0 ? segmentInfos.info(segmentInfos.size()-1) : null; > } -- 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