You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2013/11/14 09:48:57 UTC
svn commit: r1541849 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/handler/component/
core/src/java/org/apache/solr/util/ core/src/test/org/apache/solr/
core/src/test/org/apache/solr/handler/component/
Author: shalin
Date: Thu Nov 14 08:48:57 2013
New Revision: 1541849
URL: http://svn.apache.org/r1541849
Log:
SOLR-5438: DebugComponent throws NPE when used with grouping
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1541849&r1=1541848&r2=1541849&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Nov 14 08:48:57 2013
@@ -75,6 +75,12 @@ New Features
* SOLR-5308: A new 'migrate' collection API to split all documents with a
route key into another collection (shalin)
+Bug Fixes
+----------------------
+
+* SOLR-5438: DebugComponent throws NPE when used with grouping.
+ (Tomás Fernández Löbbe via shalin)
+
Other Changes
---------------------
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java?rev=1541849&r1=1541848&r2=1541849&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/component/DebugComponent.java Thu Nov 14 08:48:57 2013
@@ -19,26 +19,20 @@ package org.apache.solr.handler.componen
import static org.apache.solr.common.params.CommonParams.FQ;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.params.CommonParams;
+
import java.io.IOException;
import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
+import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.lucene.search.Query;
-import org.apache.solr.common.SolrDocumentList;
-import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.search.DocList;
import org.apache.solr.search.QueryParsing;
import org.apache.solr.util.SolrPluginUtils;
@@ -87,8 +81,14 @@ public class DebugComponent extends Sear
public void process(ResponseBuilder rb) throws IOException
{
if( rb.isDebug() ) {
+ DocList results = null;
+ //some internal grouping requests won't have results value set
+ if(rb.getResults() != null) {
+ results = rb.getResults().docList;
+ }
+
NamedList stdinfo = SolrPluginUtils.doStandardDebug( rb.req,
- rb.getQueryString(), rb.getQuery(), rb.getResults().docList, rb.isDebugQuery(), rb.isDebugResults());
+ rb.getQueryString(), rb.getQuery(), results, rb.isDebugQuery(), rb.isDebugResults());
NamedList info = rb.getDebugInfo();
if( info == null ) {
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java?rev=1541849&r1=1541848&r2=1541849&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/util/SolrPluginUtils.java Thu Nov 14 08:48:57 2013
@@ -326,10 +326,13 @@ public class SolrPluginUtils {
IndexSchema schema = searcher.getSchema();
boolean explainStruct = req.getParams().getBool(CommonParams.EXPLAIN_STRUCT, false);
- NamedList<Explanation> explain = getExplanations(query, results, searcher, schema);
- dbg.add("explain", explainStruct
- ? explanationsToNamedLists(explain)
- : explanationsToStrings(explain));
+ if (results != null) {
+ NamedList<Explanation> explain = getExplanations(query, results, searcher, schema);
+ dbg.add("explain", explainStruct
+ ? explanationsToNamedLists(explain)
+ : explanationsToStrings(explain));
+ }
+
String otherQueryS = req.getParams().get(CommonParams.EXPLAIN_OTHER);
if (otherQueryS != null && otherQueryS.length() > 0) {
DocList otherResults = doSimpleQuery(otherQueryS, req, 0, 10);
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java?rev=1541849&r1=1541848&r2=1541849&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/TestDistributedGrouping.java Thu Nov 14 08:48:57 2013
@@ -261,6 +261,9 @@ public class TestDistributedGrouping ext
// Can't validate the response, but can check if no errors occur.
simpleQuery("q", "*:*", "rows", 100, "fl", "id," + i1, "group", "true", "group.query", t1 + ":kings OR " + t1 + ":eggs", "group.limit", 10, "sort", i1 + " asc, id asc", CommonParams.TIME_ALLOWED, 1);
+
+ //Debug
+ simpleQuery("q", "*:*", "rows", 10, "fl", "id," + i1, "group", "true", "group.field", i1, "debug", "true");
}
private void simpleQuery(Object... queryParams) throws SolrServerException {
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java?rev=1541849&r1=1541848&r2=1541849&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/component/DebugComponentTest.java Thu Nov 14 08:48:57 2013
@@ -40,9 +40,9 @@ public class DebugComponentTest extends
@BeforeClass
public static void beforeClass() throws Exception {
initCore("solrconfig.xml", "schema.xml");
- assertU(adoc("id", "1", "title", "this is a title."));
- assertU(adoc("id", "2", "title", "this is another title."));
- assertU(adoc("id", "3", "title", "Mary had a little lamb."));
+ assertU(adoc("id", "1", "title", "this is a title.", "inStock_b1", "true"));
+ assertU(adoc("id", "2", "title", "this is another title.", "inStock_b1", "true"));
+ assertU(adoc("id", "3", "title", "Mary had a little lamb.", "inStock_b1", "false"));
assertU(commit());
}
@@ -147,7 +147,15 @@ public class DebugComponentTest extends
"count(//lst[@name='timing']/*)=0"
);
-
+
+ //Grouping
+ assertQ(req("q", "*:*", "debug", CommonParams.RESULTS,
+ "group", CommonParams.TRUE,
+ "group.field", "inStock_b1",
+ "debug", CommonParams.TRUE),
+ "//str[@name='rawquerystring']='*:*'",
+ "count(//lst[@name='explain']/*)=2"
+ );
}
@Test