You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by st...@apache.org on 2023/09/15 19:31:45 UTC
[solr] branch main updated: SOLR-16971 RealTimeGet with Composite router throws NPE (#1914)
This is an automated email from the ASF dual-hosted git repository.
stillalex pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 330abd4be3c SOLR-16971 RealTimeGet with Composite router throws NPE (#1914)
330abd4be3c is described below
commit 330abd4be3cb6e12ca5034e37e78b78bc8a5c961
Author: Alex D <st...@apache.org>
AuthorDate: Fri Sep 15 12:31:39 2023 -0700
SOLR-16971 RealTimeGet with Composite router throws NPE (#1914)
---
solr/CHANGES.txt | 2 ++
.../handler/component/RealTimeGetComponent.java | 5 +++-
.../solr/cloud/FullSolrCloudDistribCmdsTest.java | 34 ++++++++++++++++++++++
3 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 138ca224e11..f2e323839c9 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -190,6 +190,8 @@ Bug Fixes
* SOLR-16973: fix REMOTE_JMX_OPTS to delayed expansion (Tiziano Degaetano via Colvin Cowie)
+* SOLR-16971: RealTimeGet with Composite router throws NPE (Alex Deparvu)
+
Dependency Upgrades
---------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
index b845e050ae3..56aebd8e9d2 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/RealTimeGetComponent.java
@@ -1051,7 +1051,10 @@ public class RealTimeGetComponent extends SearchComponent {
for (String id : reqIds.allIds) {
Slice slice =
coll.getRouter()
- .getTargetSlice(params.get(ShardParams._ROUTE_, id), null, null, params, coll);
+ .getTargetSlice(id, null, params.get(ShardParams._ROUTE_), params, coll);
+ if (slice == null) {
+ continue;
+ }
List<String> idsForShard = sliceToId.get(slice.getName());
if (idsForShard == null) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
index 6a9bf85a22c..0d5e05ded27 100644
--- a/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudDistribCmdsTest.java
@@ -272,6 +272,40 @@ public class FullSolrCloudDistribCmdsTest extends SolrCloudTestCase {
}
}
+ public void testRTGCompositeRouterWithRouterField() throws Exception {
+ final CloudSolrClient cloudClient = cluster.getSolrClient();
+ final String testCollectionName =
+ "composite_collection_with_routerfield_" + NAME_COUNTER.getAndIncrement();
+ assertEquals(
+ RequestStatusState.COMPLETED,
+ CollectionAdminRequest.createCollection(testCollectionName, "_default", 2, 2)
+ .setRouterName("compositeId")
+ .setRouterField("routefield_s")
+ .setShards("shard1,shard2")
+ .processAndWait(cloudClient, DEFAULT_TIMEOUT));
+ ZkStateReader.from(cloudClient)
+ .waitForState(
+ testCollectionName,
+ DEFAULT_TIMEOUT,
+ TimeUnit.SECONDS,
+ (n, c1) -> DocCollection.isFullyActive(n, c1, 2, 2));
+
+ // Add a few documents with diff routes
+ cloudClient.add(testCollectionName, sdoc("id", "1", "routefield_s", "europe"));
+ cloudClient.add(testCollectionName, sdoc("id", "3", "routefield_s", "europe"));
+ cloudClient.add(testCollectionName, sdoc("id", "5", "routefield_s", "africa"));
+ cloudClient.add(testCollectionName, sdoc("id", "7", "routefield_s", "africa"));
+ cloudClient.commit(testCollectionName);
+
+ var docsNoRoute = cloudClient.getById(testCollectionName, List.of("3"));
+ assertEquals(0, docsNoRoute.getNumFound());
+
+ var params = new ModifiableSolrParams();
+ params.set("_route_", "europe");
+ var docsWRoute = cloudClient.getById(testCollectionName, List.of("3"), params);
+ assertEquals(1, docsWRoute.getNumFound());
+ }
+
public void testDeleteByIdCompositeRouterWithRouterField() throws Exception {
final CloudSolrClient cloudClient = cluster.getSolrClient();
final String testCollectionName =