You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2021/08/10 16:40:44 UTC
[lucene-solr] branch branch_8x updated: SOLR-14758: Fix NPE in
QueryComponent.mergeIds when using timeAllowed and sorting (#251)
This is an automated email from the ASF dual-hosted git repository.
uschindler pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new d999805 SOLR-14758: Fix NPE in QueryComponent.mergeIds when using timeAllowed and sorting (#251)
d999805 is described below
commit d99980516bd3470e9e120428914d1270d5ddf91b
Author: Uwe Schindler <us...@apache.org>
AuthorDate: Tue Aug 10 18:27:41 2021 +0200
SOLR-14758: Fix NPE in QueryComponent.mergeIds when using timeAllowed and sorting (#251)
Signed-off-by: Uwe Schindler <us...@apache.org>
Co-authored-by: Bram Van Dam <br...@intix.eu>
# Conflicts:
# solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
---
solr/CHANGES.txt | 3 +++
.../org/apache/solr/handler/component/QueryComponent.java | 2 +-
.../component/DistributedQueryComponentCustomSortTest.java | 9 +++++++++
.../org/apache/solr/BaseDistributedSearchTestCase.java | 14 +++++++++-----
4 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 10914c0..f7a8577 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -65,6 +65,9 @@ Bug Fixes
* SOLR-15575: Propagate request level basic auth creds from the top-level async CollectionAdminRequest to internally
used async requests, such as async status checking (Timothy Potter)
+* SOLR-14758: Fix NPE in QueryComponent.mergeIds when using timeAllowed and sorting
+ (Bram Van Dam, Uwe Schindler)
+
Other Changes
---------------------
* SOLR-15355: Upgrade Hadoop from 3.2.0 to 3.2.2. (Antoine Gruzelle via David Smiley)
diff --git a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
index 6622c30..1267dd5 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
@@ -919,7 +919,7 @@ public class QueryComponent extends SearchComponent
@SuppressWarnings({"rawtypes"})
NamedList sortFieldValues = (NamedList)(srsp.getSolrResponse().getResponse().get("sort_values"));
- if (sortFieldValues.size()==0 && // we bypass merging this response only if it's partial itself
+ if ((null == sortFieldValues || sortFieldValues.size()==0) && // we bypass merging this response only if it's partial itself
thisResponseIsPartial) { // but not the previous one!!
continue; //fsv timeout yields empty sort_vlaues
}
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.java
index 7efde0c..ca7e850 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedQueryComponentCustomSortTest.java
@@ -18,10 +18,12 @@ package org.apache.solr.handler.component;
import org.apache.solr.BaseDistributedSearchTestCase;
import org.apache.solr.client.solrj.response.QueryResponse;
+import org.apache.solr.response.SolrQueryResponse;
import org.junit.BeforeClass;
import org.junit.Test;
import java.nio.ByteBuffer;
+import java.util.Objects;
/**
* Test for QueryComponent's distributed querying
@@ -118,5 +120,12 @@ public class DistributedQueryComponentCustomSortTest extends BaseDistributedSear
assertFieldValues(rsp.getResults(), id, "7", "1", "6", "15","14","4", "2", "18","17","16","10", "12", "3", "5", "9", "8", "13", "11");
rsp = query("q", "*:*", "fl", "id", "sort", "payload desc, id_i asc", "rows", "20");
assertFieldValues(rsp.getResults(), id, "11", "13", "8", "9", "5", "3", "12", "10","16","17","18", "2", "4","14","15", "6", "1", "7");
+
+ // Regression check on timeAllowed in combination with sorting, SOLR-14758
+ // Should see either a complete result or a partial result, but never an NPE
+ rsp = queryServer(createParams("q", "text:d", "fl", "id", "sort", "payload desc", "rows", "20", "timeAllowed", "1"));
+ if (!Objects.equals(Boolean.TRUE, rsp.getHeader().getBooleanArg(SolrQueryResponse.RESPONSE_HEADER_PARTIAL_RESULTS_KEY))) {
+ assertFieldValues(rsp.getResults(), id, "11", "13", "12");
+ }
}
}
diff --git a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
index 26f90b2..c4ae8d7 100644
--- a/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
+++ b/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
@@ -645,11 +645,7 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
*/
protected QueryResponse query(boolean setDistribParams, Object[] q) throws Exception {
- final ModifiableSolrParams params = new ModifiableSolrParams();
-
- for (int i = 0; i < q.length; i += 2) {
- params.add(q[i].toString(), q[i + 1].toString());
- }
+ final ModifiableSolrParams params = createParams(q);
return query(setDistribParams, params);
}
@@ -1227,4 +1223,12 @@ public abstract class BaseDistributedSearchTestCase extends SolrTestCaseJ4 {
Files.createDirectories(jettyHome.toPath().resolve("cores").resolve("collection1"));
}
+ protected ModifiableSolrParams createParams(Object ... q) {
+ final ModifiableSolrParams params = new ModifiableSolrParams();
+
+ for (int i = 0; i < q.length; i += 2) {
+ params.add(q[i].toString(), q[i + 1].toString());
+ }
+ return params;
+ }
}