add assert to CategoryPath private constructor

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1436219 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2013-01-21 08:06:36 +00:00
parent d9e016c4d0
commit c1272c83bc
1 changed files with 6 additions and 0 deletions

View File

@ -48,6 +48,12 @@ public class CategoryPath implements Comparable<CategoryPath> {
// Used by subpath
private CategoryPath(CategoryPath copyFrom, int prefixLen) {
// while the code which calls this method is safe, at some point a test
// tripped on AIOOBE in toString, but we failed to reproduce. adding the
// assert as a safety check.
assert prefixLen > 0 && prefixLen <= copyFrom.components.length :
"prefixLen cannot be negative nor larger than the given components' length: prefixLen=" + prefixLen
+ " components.length=" + copyFrom.components.length;
this.components = copyFrom.components;
length = prefixLen;
}