You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2017/01/06 19:50:53 UTC

lucene-solr:branch_6x: LUCENE-7576: AutomatonTermsEnum ctor should also insist on a NORMAL CompiledAutomaton in

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x 2b66d0cb1 -> 8e974ecdc


LUCENE-7576: AutomatonTermsEnum ctor should also insist on a NORMAL CompiledAutomaton in


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8e974ecd
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8e974ecd
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8e974ecd

Branch: refs/heads/branch_6x
Commit: 8e974ecdcfc85243442fadf353cab4cb52a6cab2
Parents: 2b66d0c
Author: Mike McCandless <mi...@apache.org>
Authored: Fri Jan 6 14:50:01 2017 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Fri Jan 6 14:50:33 2017 -0500

----------------------------------------------------------------------
 .../src/java/org/apache/lucene/index/AutomatonTermsEnum.java | 3 +++
 .../core/src/test/org/apache/lucene/index/TestTermsEnum.java | 8 ++++++++
 2 files changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e974ecd/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java b/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
index 8aa10ec..411a810 100644
--- a/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
+++ b/lucene/core/src/java/org/apache/lucene/index/AutomatonTermsEnum.java
@@ -76,6 +76,9 @@ public class AutomatonTermsEnum extends FilteredTermsEnum {
    */
   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;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8e974ecd/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java b/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java
index ef3bf8b..db9de34 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java
@@ -1011,4 +1011,12 @@ public class TestTermsEnum extends LuceneTestCase {
     w.close();
     d.close();
   }
+
+  // LUCENE-7576
+  public void testInvalidAutomatonTermsEnum() throws Exception {
+    expectThrows(IllegalArgumentException.class,
+                 () -> {
+                   new AutomatonTermsEnum(TermsEnum.EMPTY, new CompiledAutomaton(Automata.makeString("foo")));
+                 });
+  }
 }