From e7b1fff87a8d677a4238bbd7a5a00c9802f57d4e Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Mon, 7 Jul 2008 16:37:30 +0000 Subject: [PATCH] fix distributed search null pointer exception when no docs are matched and debugQuery=true git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@674549 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/solr/handler/component/DebugComponent.java | 6 +++++- src/test/org/apache/solr/TestDistributedSearch.java | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/solr/handler/component/DebugComponent.java b/src/java/org/apache/solr/handler/component/DebugComponent.java index 5cd396a49e8..2fe19d52157 100644 --- a/src/java/org/apache/solr/handler/component/DebugComponent.java +++ b/src/java/org/apache/solr/handler/component/DebugComponent.java @@ -87,7 +87,7 @@ public class DebugComponent extends SearchComponent public void modifyRequest(ResponseBuilder rb, SearchComponent who, ShardRequest sreq) { if (!rb.isDebug()) return; - // Turn on debug to get explain only only when retrieving fields + // Turn on debug to get explain only when retrieving fields if ((sreq.purpose & ShardRequest.PURPOSE_GET_FIELDS) != 0) { sreq.purpose |= ShardRequest.PURPOSE_GET_DEBUG; sreq.params.set("debugQuery", "true"); @@ -130,6 +130,10 @@ public class DebugComponent extends SearchComponent } explain = HighlightComponent.removeNulls(new SimpleOrderedMap(Arrays.asList(arr))); + + if (info == null) { + info = new NamedList(); + } int idx = info.indexOf("explain",0); if (idx>=0) { info.setVal(idx, explain); diff --git a/src/test/org/apache/solr/TestDistributedSearch.java b/src/test/org/apache/solr/TestDistributedSearch.java index cf4099741e6..2301cf23f86 100755 --- a/src/test/org/apache/solr/TestDistributedSearch.java +++ b/src/test/org/apache/solr/TestDistributedSearch.java @@ -486,6 +486,9 @@ public class TestDistributedSearch extends TestCase { query("q","now their fox sat had put","fl","*,score", "debugQuery", "true"); + query("q","matchesnothing","fl","*,score", + "debugQuery", "true"); + query("q","*:*", "rows",100, "facet","true", "facet.field",t1); query("q","*:*", "rows",100, "facet","true", "facet.field",t1,"facet.limit",1); query("q","*:*", "rows",100, "facet","true", "facet.query","quick", "facet.query","all", "facet.query","*:*");