Apache Solr open-source search software
add assert to CategoryPath private constructor
Shai Ererac1272c83bce4
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.javaindex f277c054d68..61bd1548032 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/taxonomy/CategoryPath.java@@ -48,6 +48,12 @@ public class CategoryPath implements Comparable<CategoryPath> {// Used by subpathprivate 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;}