LUCENE-5879: fix empty string corner case

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1672262 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2015-04-09 08:46:03 +00:00
parent 4c83c2200c
commit 5980a4f8f7
2 changed files with 7 additions and 2 deletions

View File

@ -238,12 +238,17 @@ final public class Automata {
minInclusive = true;
}
// Empty string corner case:
// Empty string corner cases:
if (max != null && maxInclusive == false && max.length == 1 && max.bytes[max.offset] == 0) {
max = new BytesRef();
maxInclusive = true;
}
if (min != null && minInclusive == false && min.length == 0) {
min = new BytesRef(new byte[1]);
minInclusive = true;
}
int cmp;
if (max != null) {
cmp = min.compareTo(max);

View File

@ -1127,7 +1127,7 @@ public class TestAutomaton extends LuceneTestCase {
System.out.println("Minimized:\n" + minA.toDot());
System.out.println("minTerm=" + minTerm + " minInclusive=" + minInclusive);
System.out.println("maxTerm=" + maxTerm + " maxInclusive=" + maxInclusive);
fail("auotmaton was not minimal");
fail("automaton was not minimal");
}
if (VERBOSE) {