Skip to content

Apache Lucene open-source search software

LUCENE-1140 patch to fix StandardAnalyzer stop set NPE and test

Grant Ingersoll82980ed7c4c8
diff --git a/CHANGES.txt b/CHANGES.txt
index f30c779bfb7..75e068ed3c7 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -228,6 +228,7 @@ Bug fixes
replaceInvalidAcronym which defaults to false, the current, incorrect behavior. Setting
this flag to true fixes the problem. This flag is a temporary fix and is already
marked 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 of
first 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.java
index 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.java
index 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 names
assertAnalyzesTo(a, "www.nutch.org", new String[]{"www.nutch.org"});