lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r1581237 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/CHANGES.txt solr/core/ solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
Date Tue, 25 Mar 2014 05:10:14 GMT
Author: shalin
Date: Tue Mar 25 05:10:14 2014
New Revision: 1581237

URL: http://svn.apache.org/r1581237
Log:
SOLR-5905: CollapsingQParserPlugin throws a NPE if required 'field' param is missing

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/CHANGES.txt   (contents, props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java

Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1581237&r1=1581236&r2=1581237&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Tue Mar 25 05:10:14 2014
@@ -277,6 +277,9 @@ Bug Fixes
 * SOLR-5899: CloudSolrServer's RouteResponse and RouteException should be
   publicly accessible. (Mark Miller, shalin)
 
+* SOLR-5905: CollapsingQParserPlugin throws a NPE if required 'field' param is missing.
+  (Spyros Kapnissis via shalin)
+
 Other Changes
 ---------------------
 

Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java?rev=1581237&r1=1581236&r2=1581237&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/search/CollapsingQParserPlugin.java
Tue Mar 25 05:10:14 2014
@@ -42,6 +42,7 @@ import org.apache.lucene.search.Scorer;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.FixedBitSet;
+import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
@@ -211,6 +212,9 @@ public class CollapsingQParserPlugin ext
 
     public CollapsingPostFilter(SolrParams localParams, SolrParams params, SolrQueryRequest
request) throws IOException {
       this.field = localParams.get("field");
+      if (this.field == null) {
+        throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Required 'field' param
is missing.");
+      }
       this.max = localParams.get("max");
       this.min = localParams.get("min");
       if(this.min != null || this.max != null) {

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java?rev=1581237&r1=1581236&r2=1581237&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/search/TestCollapseQParserPlugin.java
Tue Mar 25 05:10:14 2014
@@ -18,6 +18,7 @@
 package org.apache.solr.search;
 
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.junit.Before;
 import org.junit.BeforeClass;
@@ -296,4 +297,14 @@ public class TestCollapseQParserPlugin e
     assertQ(req(params), "*[count(//doc)=2]");
 
   }
+
+  @Test
+  public void testMissingFieldParam() throws Exception {
+    ModifiableSolrParams params = new ModifiableSolrParams();
+    params.add("q", "*:*");
+    params.add("fq", "{!collapse}");
+    assertQEx("It should respond with a bad request when the 'field' param is missing", req(params),
+        SolrException.ErrorCode.BAD_REQUEST);
+  }
+
 }



Mime
View raw message