Apache Lucene open-source search software
LUCENE-3327: fix AIOOBE in test case when verbose is true
Michael McCandless82d74a2e86cf
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 84d3ca35fb0..739fb1e3baf 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -559,6 +559,11 @@ Optimizationsgreatly reduce RAM required during building, and CPU consumed, atthe cost of a somewhat larger FST. (Mike McCandless)+Test Cases++* LUCENE-3327: Fix AIOOBE when TestFSTs is run with+ -Dtests.verbose=true (James Dyer via Mike McCandless)+======================= Lucene 3.3.0 =======================Changes in backwards compatibility policydiff --git a/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java b/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.javaindex 46a3673837e..c31d4dd41ab 100644--- a/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java+++ b/lucene/src/test/org/apache/lucene/util/fst/TestFSTs.java@@ -830,7 +830,7 @@ public class TestFSTs extends LuceneTestCase {final IntsRef prefix = ent.getKey();final CountMinOutput<T> cmo = ent.getValue();if (VERBOSE) {- System.out.println(" term=" + inputToString(inputMode, prefix) + " count=" + cmo.count + " isLeaf=" + cmo.isLeaf + " output=" + outputs.outputToString(cmo.output) + " isFinal=" + cmo.isFinal);+ System.out.println(" term prefix=" + inputToString(inputMode, prefix, false) + " count=" + cmo.count + " isLeaf=" + cmo.isLeaf + " output=" + outputs.outputToString(cmo.output) + " isFinal=" + cmo.isFinal);}final boolean keep;if (prune1 > 0) {@@ -897,7 +897,7 @@ public class TestFSTs extends LuceneTestCase {IntsRefFSTEnum.InputOutput<T> current;while((current = fstEnum.next()) != null) {if (VERBOSE) {- System.out.println(" fstEnum.next term=" + inputToString(inputMode, current.input) + " output=" + outputs.outputToString(current.output));+ System.out.println(" fstEnum.next prefix=" + inputToString(inputMode, current.input, false) + " output=" + outputs.outputToString(current.output));}final CountMinOutput cmo = prefixes.get(current.input);assertNotNull(cmo);@@ -920,7 +920,7 @@ public class TestFSTs extends LuceneTestCase {final CountMinOutput<T> cmo = ent.getValue();final T output = run(fst, ent.getKey(), stopNode);if (VERBOSE) {- System.out.println("TEST: verify term=" + inputToString(inputMode, ent.getKey()) + " output=" + outputs.outputToString(cmo.output));+ System.out.println("TEST: verify prefix=" + inputToString(inputMode, ent.getKey(), false) + " output=" + outputs.outputToString(cmo.output));}// if (cmo.isFinal && !cmo.isLeaf) {if (cmo.isFinal) {@@ -982,9 +982,15 @@ public class TestFSTs extends LuceneTestCase {public void testBigSet() throws IOException {testRandomWords(_TestUtil.nextInt(random, 50000, 60000), 1);}-+private static String inputToString(int inputMode, IntsRef term) {- if (inputMode == 0) {+ return inputToString(inputMode, term, true);+ }++ private static String inputToString(int inputMode, IntsRef term, boolean isValidUnicode) {+ if (!isValidUnicode) {+ return term.toString();+ } else if (inputMode == 0) {// utf8return toBytesRef(term).utf8ToString() + " " + term;} else {