You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Karthick Sankarachary (JIRA)" <ji...@apache.org> on 2010/04/05 05:45:27 UTC
[jira] Created: (LUCENE-2365) Finding Newest Segment In Empty Index
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
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/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
[jira] Assigned: (LUCENE-2365) Finding Newest Segment In Empty
Index
Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-2365?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michael McCandless reassigned LUCENE-2365:
------------------------------------------
Assignee: Michael McCandless
> 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.0.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
[jira] Resolved: (LUCENE-2365) Finding Newest Segment In Empty
Index
Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
[ 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
[jira] Commented: (LUCENE-2365) Finding Newest Segment In Empty
Index
Posted by "Michael McCandless (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-2365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12853497#action_12853497 ]
Michael McCandless commented on LUCENE-2365:
--------------------------------------------
Thanks, patch looks good; I'll commit shortly!
> 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
> Priority: Minor
> Fix For: 3.0.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
[jira] Updated: (LUCENE-2365) Finding Newest Segment In Empty Index
Posted by "Karthick Sankarachary (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/LUCENE-2365?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Karthick Sankarachary updated LUCENE-2365:
------------------------------------------
Attachment: LUCENE-2365.patch
The unit test case that expose this issue, along with the proposed patch can be found in LUCENE-2365.patch.
> 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
> Priority: Minor
> Fix For: 3.0.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