Apache Solr open-source search software
LUCENE-1140 patch to fix StandardAnalyzer stop set NPE and test
Grant Ingersoll82980ed7c4c8
diff --git a/CHANGES.txt b/CHANGES.txtindex f30c779bfb7..75e068ed3c7 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -228,6 +228,7 @@ Bug fixesreplaceInvalidAcronym which defaults to false, the current, incorrect behavior. Settingthis flag to true fixes the problem. This flag is a temporary fix and is alreadymarked as being deprecated. 3.x will implement the correct approach. (Shai Erera via Grant Ingersoll)+ LUCENE-1140: Fixed NPE caused by 1068 (Alexei Dets via Grant Ingersoll)28. LUCENE-749: ChainedFilter behavior fixed when logic offirst filter is ANDNOT. (Antonio Bruno via Doron Cohen)diff --git a/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java b/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.javaindex 126b9ab4010..42daad14934 100644--- a/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java+++ b/src/java/org/apache/lucene/analysis/standard/StandardAnalyzer.java@@ -85,6 +85,7 @@ public class StandardAnalyzer extends Analyzer {* @deprecated Remove in 3.X and make true the only valid value*/public StandardAnalyzer(boolean replaceInvalidAcronym) {+ this(STOP_WORDS);this.replaceInvalidAcronym = replaceInvalidAcronym;}diff --git a/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java b/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.javaindex 6209f3dec7e..de43d745607 100644--- a/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java+++ b/src/test/org/apache/lucene/analysis/TestStandardAnalyzer.java@@ -120,6 +120,16 @@ public class TestStandardAnalyzer extends LuceneTestCase {assertAnalyzesTo(a, "Excite@Home", new String[]{"excite@home"});}+ public void testLucene1140() throws Exception {+ try {+ StandardAnalyzer analyzer = new StandardAnalyzer(true);+ assertAnalyzesTo(analyzer, "www.nutch.org.", new String[]{ "www.nutch.org" }, new String[] { "<HOST>" });+ } catch (NullPointerException e) {+ assertTrue("Should not throw an NPE and it did", false);+ }++ }+public void testDomainNames() throws Exception {// domain namesassertAnalyzesTo(a, "www.nutch.org", new String[]{"www.nutch.org"});