Skip to content
Permalink
Browse files

LUCENE-7576: AutomatonTermsEnum ctor should also insist on a NORMAL C…

…ompiledAutomaton in
  • Loading branch information...
mikemccand committed Jan 6, 2017
1 parent cd4f908 commit ebb5c7e6768c03c83be4aa3abdab22e16cb67c2c
@@ -76,6 +76,9 @@
*/
public AutomatonTermsEnum(TermsEnum tenum, CompiledAutomaton compiled) {
super(tenum);
if (compiled.type != CompiledAutomaton.AUTOMATON_TYPE.NORMAL) {
throw new IllegalArgumentException("please use CompiledAutomaton.getTermsEnum instead");
}
this.finite = compiled.finite;
this.runAutomaton = compiled.runAutomaton;
assert this.runAutomaton != null;
@@ -1016,4 +1016,12 @@ public void testIntersectRegexp() throws Exception {
w.close();
d.close();
}

// LUCENE-7576
public void testInvalidAutomatonTermsEnum() throws Exception {
expectThrows(IllegalArgumentException.class,
() -> {
new AutomatonTermsEnum(TermsEnum.EMPTY, new CompiledAutomaton(Automata.makeString("foo")));
});
}
}

0 comments on commit ebb5c7e

Please sign in to comment.
You can’t perform that action at this time.