From 742dccd20292187e99a481335d550e05516c34ad Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Thu, 5 Feb 2009 08:41:14 +0000 Subject: [PATCH] SOLR-435 -- NullPointerException with no query or empty query git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@741046 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 ++ .../org/apache/solr/handler/component/QueryComponent.java | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index a8d3c7d4075..3f893acb583 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -236,6 +236,8 @@ Bug Fixes 27. SOLR-991: Better error message when parsing solrconfig.xml fails due to malformed XML. Error message notes the name of the file being parsed. (Michael Henson via shalin) +28. SOLR-435: NullPointerException with no query or empty query (ryan, Lars Kotthoff via shalin) + Other Changes ---------------------- diff --git a/src/java/org/apache/solr/handler/component/QueryComponent.java b/src/java/org/apache/solr/handler/component/QueryComponent.java index 84571bde052..d882e0bc2e1 100644 --- a/src/java/org/apache/solr/handler/component/QueryComponent.java +++ b/src/java/org/apache/solr/handler/component/QueryComponent.java @@ -74,7 +74,12 @@ public class QueryComponent extends SearchComponent defType = defType==null ? OldLuceneQParserPlugin.NAME : defType; if (rb.getQueryString() == null) { - rb.setQueryString( params.get( CommonParams.Q ) ); + rb.setQueryString(params.get(CommonParams.Q)); + String queryString = params.get(CommonParams.Q); + if (queryString == null) { + throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, + "Missing or empty required parameter: q"); + } } try {