lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karthick Sankarachary (JIRA)" <>
Subject [jira] Created: (LUCENE-2365) Finding Newest Segment In Empty Index
Date Mon, 05 Apr 2010 03:45:27 GMT
Finding Newest Segment In Empty Index

                 Key: LUCENE-2365
             Project: Lucene - Java
          Issue Type: Bug
          Components: Index
    Affects Versions: 3.0.1
            Reporter: Karthick Sankarachary
            Priority: Minor
             Fix For: 3.0.1

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/	(revision 930788)
+++ lucene/src/java/org/apache/lucene/index/	(working copy)
@@ -4587,7 +4587,7 @@
   // utility routines for tests
   SegmentInfo newestSegment() {
-    return;
+    return segmentInfos.size() > 0 ? : 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:
For additional commands, e-mail:

View raw message