mirror of https://github.com/apache/lucene.git
SOLR-5905: CollapsingQParserPlugin throws a NPE if required 'field' param is missing
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1581234 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
991fba9981
commit
b9814a4a89
|
@ -330,6 +330,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
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -211,6 +211,9 @@ public class CollapsingQParserPlugin extends QParserPlugin {
|
|||
|
||||
public CollapsingPostFilter(SolrParams localParams, SolrParams params, SolrQueryRequest request) throws IOException {
|
||||
this.field = localParams.get("field");
|
||||
if (this.field == null) {
|
||||
throw new IllegalStateException("Required 'field' param is missing.");
|
||||
}
|
||||
this.max = localParams.get("max");
|
||||
this.min = localParams.get("min");
|
||||
if(this.min != null || this.max != null) {
|
||||
|
|
|
@ -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 extends SolrTestCaseJ4 {
|
|||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue