mirror of https://github.com/apache/lucene.git
SOLR-6023: FieldAnalysisRequestHandler throws NPE if no parameters are supplied
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1592195 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7db6edeb75
commit
d67884a07c
|
@ -132,6 +132,9 @@ Bug Fixes
|
|||
* SOLR-6037: Fixed incorrect max/sum/stddev for Date fields in StatsComponent
|
||||
(Brett Lucey, hossman)
|
||||
|
||||
* SOLR-6023: FieldAnalysisRequestHandler throws NPE if no parameters are supplied.
|
||||
(shalin)
|
||||
|
||||
Other Changes
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ public class FieldAnalysisRequestHandler extends AnalysisRequestHandlerBase {
|
|||
}
|
||||
analysisRequest.setQuery(solrParams.get(AnalysisParams.QUERY, solrParams.get(CommonParams.Q)));
|
||||
|
||||
String value = solrParams.get(AnalysisParams.FIELD_VALUE);
|
||||
String value = solrParams.required().get(AnalysisParams.FIELD_VALUE);
|
||||
|
||||
Iterable<ContentStream> streams = req.getContentStreams();
|
||||
if (streams != null) {
|
||||
|
|
|
@ -19,6 +19,7 @@ package org.apache.solr.handler;
|
|||
|
||||
import org.apache.lucene.analysis.MockTokenizer;
|
||||
import org.apache.lucene.analysis.core.WhitespaceTokenizer;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.AnalysisParams;
|
||||
import org.apache.solr.common.params.CommonParams;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
|
@ -379,5 +380,20 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
|
|||
assertToken(tokenList.get(4), new TokenInfo("a", null, "word", 12, 13, 4, new int[]{3,4,4}, null, false));
|
||||
assertToken(tokenList.get(5), new TokenInfo("test", null, "word", 14, 18, 5, new int[]{4,5,5}, null, false));
|
||||
}
|
||||
|
||||
|
||||
public void testRequiredParamHandling() throws Exception {
|
||||
ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.add(CommonParams.Q, "fox brown");
|
||||
|
||||
SolrQueryRequest req = new LocalSolrQueryRequest(h.getCore(), params);
|
||||
try {
|
||||
FieldAnalysisRequest request = handler.resolveAnalysisRequest(req);
|
||||
fail("A request with no parameters should not have succeeded");
|
||||
} catch (NullPointerException npe) {
|
||||
fail("A request with no paramters should not result in NPE");
|
||||
} catch (SolrException e) {
|
||||
assertEquals("A request with no parameters should have returned a BAD_REQUEST error", e.code(),
|
||||
SolrException.ErrorCode.BAD_REQUEST.code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue