mirror of https://github.com/apache/lucene.git
LUCENE-5473: throw IAE not NPE when synonym map was empty
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1571986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c36c4d7264
commit
0082b500ce
|
@ -84,6 +84,10 @@ Bug fixes
|
|||
empty list of clauses. This can happen for example, when a wildcard matches
|
||||
no terms. (Tim Allison via Robert Muir)
|
||||
|
||||
* LUCENE-5473: Throw IllegalArgumentException, not
|
||||
NullPointerException, if the synonym map is empty when creating
|
||||
SynonymFilter (帅广应 via Mike McCandless)
|
||||
|
||||
Test Framework
|
||||
|
||||
* LUCENE-5449: Rename _TestUtil and _TestHelper to remove the leading _.
|
||||
|
|
|
@ -263,10 +263,10 @@ public final class SynonymFilter extends TokenFilter {
|
|||
this.synonyms = synonyms;
|
||||
this.ignoreCase = ignoreCase;
|
||||
this.fst = synonyms.fst;
|
||||
this.fstReader = fst.getBytesReader();
|
||||
if (fst == null) {
|
||||
throw new IllegalArgumentException("fst must be non-null");
|
||||
}
|
||||
this.fstReader = fst.getBytesReader();
|
||||
|
||||
// Must be 1+ so that when roll buffer is at full
|
||||
// lookahead we can distinguish this full buffer from
|
||||
|
|
|
@ -926,4 +926,16 @@ public class TestSynonymMapFilter extends BaseTokenStreamTestCase {
|
|||
new int[] { 8, 22, 15, 22 },
|
||||
new int[] { 1, 0, 1, 1 });
|
||||
}
|
||||
|
||||
public void testEmpty() throws Exception {
|
||||
Tokenizer tokenizer = new MockTokenizer();
|
||||
tokenizer.setReader(new StringReader("aa bb"));
|
||||
try {
|
||||
new SynonymFilter(tokenizer, new SynonymMap.Builder(true).build(), true);
|
||||
fail("did not hit expected exception");
|
||||
} catch (IllegalArgumentException iae) {
|
||||
// expected
|
||||
assertEquals("fst must be non-null", iae.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue