Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-17625: NamedList.findRecursive -> _get (#3355)

wildtusker51841d7d8423
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7cf56b84a49..e9c98fc6532 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -342,6 +342,9 @@ Other Changes
* SOLR-17651: Add System.exit() in forbidden APIs, and make sure CLI unit tests never call it. (Pierre Salagnac)
+* SOLR-17625: Replaced NamedList.findRecursive usages with _get, which can do Map traversal, and
+ thus makes it easier to transition intermediate NamedLists to Maps. (Gaurav Tuli)
+
================== 9.8.1 ==================
Bug Fixes
---------------------
diff --git a/solr/core/src/java/org/apache/solr/cli/AssertTool.java b/solr/core/src/java/org/apache/solr/cli/AssertTool.java
index 74a3176d0ce..e0349cbf328 100644
--- a/solr/core/src/java/org/apache/solr/cli/AssertTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/AssertTool.java
@@ -21,6 +21,7 @@ import java.lang.invoke.MethodHandles;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.FileOwnerAttributeView;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.Option;
@@ -280,7 +281,7 @@ public class AssertTool extends ToolBase {
System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeoutMs, TimeUnit.MILLISECONDS);
try (SolrClient solrClient = CLIUtils.getSolrClient(url, credentials)) {
NamedList<Object> response = solrClient.request(new HealthCheckRequest());
- Integer statusCode = (Integer) response.findRecursive("responseHeader", "status");
+ Integer statusCode = (Integer) response._get(List.of("responseHeader", "status"), null);
CLIUtils.checkCodeForAuthError(statusCode);
} catch (IOException | SolrServerException e) {
log.debug("Opening connection to {} failed, Solr does not seem to be running", url, e);
diff --git a/solr/core/src/java/org/apache/solr/cli/ConfigTool.java b/solr/core/src/java/org/apache/solr/cli/ConfigTool.java
index b70f4c1b9a5..ce7b644c457 100644
--- a/solr/core/src/java/org/apache/solr/cli/ConfigTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/ConfigTool.java
@@ -18,6 +18,7 @@
package org.apache.solr.cli;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.MissingArgumentException;
@@ -124,7 +125,7 @@ public class ConfigTool extends ToolBase {
try (SolrClient solrClient =
CLIUtils.getSolrClient(solrUrl, cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION))) {
NamedList<Object> result = SolrCLI.postJsonToSolr(solrClient, updatePath, jsonBody);
- Integer statusCode = (Integer) result.findRecursive("responseHeader", "status");
+ Integer statusCode = (Integer) result._get(List.of("responseHeader", "status"), null);
if (statusCode == 0) {
if (value != null) {
echo("Successfully " + action + " " + property + " to " + value);
diff --git a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java
index afabd5275d3..bf795a51596 100644
--- a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java
@@ -173,9 +173,10 @@ public class HealthcheckTool extends ToolBase {
solrClient.request(
new GenericSolrRequest(
SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH));
- uptime = SolrCLI.uptime((Long) systemInfo.findRecursive("jvm", "jmx", "upTimeMS"));
- String usedMemory = (String) systemInfo.findRecursive("jvm", "memory", "used");
- String totalMemory = (String) systemInfo.findRecursive("jvm", "memory", "total");
+ uptime =
+ SolrCLI.uptime((Long) systemInfo._get(List.of("jvm", "jmx", "upTimeMS"), null));
+ String usedMemory = systemInfo._getStr(List.of("jvm", "memory", "used"), null);
+ String totalMemory = systemInfo._getStr(List.of("jvm", "memory", "total"), null);
memory = usedMemory + " of " + totalMemory;
}
diff --git a/solr/core/src/java/org/apache/solr/cli/StatusTool.java b/solr/core/src/java/org/apache/solr/cli/StatusTool.java
index 43af8ebb34d..2f7422c054f 100644
--- a/solr/core/src/java/org/apache/solr/cli/StatusTool.java
+++ b/solr/core/src/java/org/apache/solr/cli/StatusTool.java
@@ -314,12 +314,12 @@ public class StatusTool extends ToolBase {
String solrHome = (String) info.get("solr_home");
status.put("solr_home", solrHome != null ? solrHome : "?");
- status.put("version", info.findRecursive("lucene", "solr-impl-version"));
- status.put("startTime", info.findRecursive("jvm", "jmx", "startTime").toString());
- status.put("uptime", SolrCLI.uptime((Long) info.findRecursive("jvm", "jmx", "upTimeMS")));
+ status.put("version", info._getStr(List.of("lucene", "solr-impl-version"), null));
+ status.put("startTime", info._getStr(List.of("jvm", "jmx", "startTime"), null));
+ status.put("uptime", SolrCLI.uptime((Long) info._get(List.of("jvm", "jmx", "upTimeMS"), null)));
- String usedMemory = (String) info.findRecursive("jvm", "memory", "used");
- String totalMemory = (String) info.findRecursive("jvm", "memory", "total");
+ String usedMemory = info._getStr(List.of("jvm", "memory", "used"), null);
+ String totalMemory = info._getStr(List.of("jvm", "memory", "total"), null);
status.put("memory", usedMemory + " of " + totalMemory);
// if this is a Solr in solrcloud mode, gather some basic cluster info
@@ -344,11 +344,11 @@ public class StatusTool extends ToolBase {
// TODO add booleans to request just what we want; not everything
NamedList<Object> json = solrClient.request(new CollectionAdminRequest.ClusterStatus());
- List<String> liveNodes = (List<String>) json.findRecursive("cluster", "live_nodes");
+ List<String> liveNodes = (List<String>) json._get(List.of("cluster", "live_nodes"), null);
cloudStatus.put("liveNodes", String.valueOf(liveNodes.size()));
// TODO get this as a metric from the metrics API instead, or something else.
- var collections = (Map<String, Object>) json.findRecursive("cluster", "collections");
+ var collections = (Map<String, Object>) json._get(List.of("cluster", "collections"), null);
cloudStatus.put("collections", String.valueOf(collections.size()));
return cloudStatus;
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java b/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java
index 662221cca7f..12ac6a4d89a 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/SplitShardCmd.java
@@ -862,14 +862,15 @@ public class SplitShardCmd implements CollApiCmds.CollectionApiCommand {
SolrRequest.METHOD.GET, "/admin/metrics", SolrRequest.SolrRequestType.ADMIN, params)
.process(cloudManager.getSolrClient());
- Number size = (Number) rsp.getResponse().findRecursive("metrics", indexSizeMetricName);
+ Number size = (Number) rsp.getResponse()._get(List.of("metrics", indexSizeMetricName), null);
if (size == null) {
log.warn("cannot verify information for parent shard leader");
return;
}
double indexSize = size.doubleValue();
- Number freeSize = (Number) rsp.getResponse().findRecursive("metrics", freeDiskSpaceMetricName);
+ Number freeSize =
+ (Number) rsp.getResponse()._get(List.of("metrics", freeDiskSpaceMetricName), null);
if (freeSize == null) {
log.warn("missing node disk space information for parent shard leader");
return;
diff --git a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
index 45a8c1d7a19..ebde36c4a4f 100644
--- a/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/component/SearchHandler.java
@@ -609,15 +609,18 @@ public class SearchHandler extends RequestHandlerBase
if (resp == null) {
return false;
}
- Object recursive = resp.findRecursive("responseHeader", "partialResults");
+ Object recursive =
+ resp._get(List.of("responseHeader", "partialResults"), null);
if (recursive != null) {
Object message =
"[Shard:"
+ response.getShardAddress()
+ "]"
- + resp.findRecursive(
- "responseHeader",
- RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY);
+ + resp._get(
+ List.of(
+ "responseHeader",
+ RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY),
+ null);
detailMesg.compareAndSet(null, message); // first one, ingore rest
}
return recursive != null;
diff --git a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
index 49863a74700..fc6e7c84bdd 100644
--- a/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
+++ b/solr/core/src/java/org/apache/solr/packagemanager/PackageManager.java
@@ -284,7 +284,7 @@ public class PackageManager implements Closeable {
NamedList<Object> response =
solrClient.request(
new GenericV2SolrRequest(SolrRequest.METHOD.GET, PackageUtils.CLUSTERPROPS_PATH));
- Integer statusCode = (Integer) response.findRecursive("responseHeader", "status");
+ Integer statusCode = (Integer) response._get(List.of("responseHeader", "status"), null);
if (statusCode == null || statusCode == ErrorCode.NOT_FOUND.code) {
// Cluster props doesn't exist, that means there are no cluster level plugins installed.
result = Collections.emptyMap();
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
index 6ce8503323d..307f0c40c16 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java
@@ -287,8 +287,8 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
cluster.waitForActiveCollection(collectionName, 2, 4);
- String nodeName = (String) response._get("success[0]/key", null);
- String corename = (String) response._get(asList("success", nodeName, "core"), null);
+ String nodeName = response._getStr("success[0]/key", null);
+ String corename = response._getStr(asList("success", nodeName, "core"), null);
try (SolrClient coreClient =
getHttpSolrClient(cluster.getZkStateReader().getBaseUrlForNodeName(nodeName))) {
@@ -620,19 +620,23 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
CollectionAdminResponse rsp = req.process(cluster.getSolrClient());
assertEquals(0, rsp.getStatus());
assertNotNull(rsp.getResponse().get(collectionName));
- assertNotNull(rsp.getResponse().findRecursive(collectionName, "properties"));
+ assertNotNull(rsp.getResponse()._get(List.of(collectionName, "properties"), null));
final var collPropMap =
- (Map<String, Object>) rsp.getResponse().findRecursive(collectionName, "properties");
+ (Map<String, Object>) rsp.getResponse()._get(List.of(collectionName, "properties"), null);
assertEquals("conf2", collPropMap.get("configName"));
assertEquals(2L, collPropMap.get("nrtReplicas"));
assertEquals("0", collPropMap.get("tlogReplicas"));
assertEquals("0", collPropMap.get("pullReplicas"));
assertEquals(
- 2, ((NamedList<Object>) rsp.getResponse().findRecursive(collectionName, "shards")).size());
- assertNotNull(rsp.getResponse().findRecursive(collectionName, "shards", "shard1", "leader"));
+ 2,
+ ((NamedList<Object>) rsp.getResponse()._get(List.of(collectionName, "shards"), null))
+ .size());
+ assertNotNull(
+ rsp.getResponse()._get(List.of(collectionName, "shards", "shard1", "leader"), null));
// Ensure more advanced info is not returned
assertNull(
- rsp.getResponse().findRecursive(collectionName, "shards", "shard1", "leader", "segInfos"));
+ rsp.getResponse()
+ ._get(List.of(collectionName, "shards", "shard1", "leader", "segInfos"), null));
// Returns segment metadata iff requested
req = CollectionAdminRequest.collectionStatus(collectionName);
@@ -689,7 +693,7 @@ public class CollectionsAPISolrJTest extends SolrCloudTestCase {
assertEquals(0, rsp.getStatus());
@SuppressWarnings({"unchecked"})
List<Object> nonCompliant =
- (List<Object>) rsp.getResponse().findRecursive(collectionName, "schemaNonCompliant");
+ (List<Object>) rsp.getResponse()._get(List.of(collectionName, "schemaNonCompliant"), null);
assertEquals(nonCompliant.toString(), 1, nonCompliant.size());
assertTrue(nonCompliant.toString(), nonCompliant.contains("(NONE)"));
@SuppressWarnings({"unchecked"})
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java
index 2e1f6dd7912..38ad8bf4f3d 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java
@@ -319,7 +319,7 @@ public class TestPullReplica extends SolrCloudTestCase {
"Replicas shouldn't process the add document request: " + statsResponse,
((Map<String, Object>)
(statsResponse.getResponse())
- .findRecursive("plugins", "UPDATE", "updateHandler", "stats"))
+ ._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null))
.get("UPDATE.updateHandler.adds"));
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java b/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java
index 902c9e2c6de..cc52117feed 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java
@@ -40,6 +40,7 @@ import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.DocCollection;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.Slice;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.util.SecurityJson;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -153,10 +154,9 @@ public class TestPullReplicaWithAuth extends SolrCloudTestCase {
@SuppressWarnings("unchecked")
private Object getUpdateHandlerMetric(QueryResponse statsResponse, String metric) {
+ NamedList<Object> entries = statsResponse.getResponse();
return ((Map<String, Object>)
- statsResponse
- .getResponse()
- .findRecursive("plugins", "UPDATE", "updateHandler", "stats"))
+ entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null))
.get(metric);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java b/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java
index 57a88d0ea58..3219d0e05e8 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java
@@ -29,6 +29,7 @@ import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
import org.apache.solr.common.cloud.LiveNodesPredicate;
import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.embedded.JettySolrRunner;
import org.junit.After;
import org.junit.Before;
@@ -237,7 +238,8 @@ public class TestSkipOverseerOperations extends SolrCloudTestCase {
* <p>The update happens in org.apache.solr.cloud.Overseer.ClusterStateUpdater.processQueueItem()
*/
private int getNumLeaderOperations(CollectionAdminResponse resp) {
- return (int) resp.getResponse().findRecursive("overseer_operations", "leader", "requests");
+ NamedList<Object> entries = resp.getResponse();
+ return (int) entries._get(List.of("overseer_operations", "leader", "requests"), null);
}
/**
@@ -245,7 +247,8 @@ public class TestSkipOverseerOperations extends SolrCloudTestCase {
* org.apache.solr.cloud.overseer.OverseerAction#STATE} message that sets replica properties
*/
private int getNumStateOperations(CollectionAdminResponse resp) {
- return (int) resp.getResponse().findRecursive("overseer_operations", "state", "requests");
+ NamedList<Object> entries = resp.getResponse();
+ return (int) entries._get(List.of("overseer_operations", "state", "requests"), null);
}
private String getOverseerLeader() throws IOException, SolrServerException {
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
index a7a0306b04c..84d3e2066ab 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
@@ -286,6 +286,7 @@ public class TestTlogReplica extends SolrCloudTestCase {
"qt", "/admin/plugins",
"stats", "true");
QueryResponse statsResponse = tlogReplicaClient.query(req);
+ NamedList<Object> entries = (statsResponse.getResponse());
assertEquals(
"Append replicas should recive all updates. Replica: "
+ r
@@ -293,8 +294,7 @@ public class TestTlogReplica extends SolrCloudTestCase {
+ statsResponse,
1L,
((Map<String, Object>)
- (statsResponse.getResponse())
- .findRecursive("plugins", "UPDATE", "updateHandler", "stats"))
+ entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null))
.get("UPDATE.updateHandler.cumulativeAdds.count"));
break;
} catch (AssertionError e) {
diff --git a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java
index 8cf5dca2cc7..f47a08ca8e4 100644
--- a/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java
+++ b/solr/core/src/test/org/apache/solr/cloud/api/collections/TestRequestStatusCollectionAPI.java
@@ -21,6 +21,7 @@ import static org.hamcrest.Matchers.containsString;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.solr.client.solrj.SolrClient;
@@ -79,7 +80,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
NamedList<Object> createResponse = null;
try {
createResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- message = (String) createResponse.findRecursive("status", "msg");
+ message = createResponse._getStr(List.of("status", "msg"), null);
} catch (SolrServerException | IOException e) {
log.error("error sending request", e);
}
@@ -122,7 +123,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
NamedList<Object> splitResponse = null;
try {
splitResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- message = (String) splitResponse.findRecursive("status", "msg");
+ message = splitResponse._getStr(List.of("status", "msg"), null);
} catch (SolrServerException | IOException e) {
log.error("error sending request", e);
}
@@ -154,7 +155,7 @@ public class TestRequestStatusCollectionAPI extends BasicDistributedZkTest {
try {
NamedList<Object> response = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS);
- message = (String) response.findRecursive("status", "msg");
+ message = response._getStr(List.of("status", "msg"), null);
} catch (SolrServerException | IOException e) {
log.error("error sending request", e);
}
diff --git a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
index 2cc1ba80c78..36b293ed8ab 100644
--- a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java
@@ -800,7 +800,7 @@ public class FieldAnalysisRequestHandlerTest extends AnalysisRequestHandlerTestB
// just test that we see "900" in the flags attribute here
@SuppressWarnings({"unchecked", "rawtypes"})
List<NamedList> tokenInfoList =
- (List<NamedList>) result.findRecursive("index", CustomTokenFilter.class.getName());
+ (List<NamedList>) result._get(List.of("index", CustomTokenFilter.class.getName()), null);
// '1' from CustomTokenFilter plus 900 from CustomFlagsAttributeImpl.
assertEquals(
901,
diff --git a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
index 4c3709f5ae5..dffbdae399c 100644
--- a/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/admin/MetricsHandlerTest.java
@@ -27,6 +27,7 @@ import io.prometheus.metrics.model.snapshots.MetricSnapshot;
import io.prometheus.metrics.model.snapshots.MetricSnapshots;
import java.util.Arrays;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.MapWriter;
@@ -479,7 +480,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
key1),
resp);
NamedList<?> values = resp.getValues();
- Object val = values.findRecursive("metrics", key1);
+ Object val = values._get(List.of("metrics", key1), null);
assertNotNull(val);
assertTrue(val instanceof MapWriter);
assertTrue(((MapWriter) val)._size() >= 2);
@@ -573,8 +574,8 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
values = resp.getValues();
NamedList<?> metrics = (NamedList<?>) values.get("metrics");
assertEquals(0, metrics.size());
- assertNotNull(values.findRecursive("errors", "foo"));
- assertNotNull(values.findRecursive("errors", "foo:bar:baz:xyz"));
+ assertNotNull(values._get(List.of("errors", "foo"), null));
+ assertNotNull(values._get(List.of("errors", "foo:bar:baz:xyz"), null));
// unknown registry
resp = new SolrQueryResponse();
@@ -590,7 +591,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
values = resp.getValues();
metrics = (NamedList<?>) values.get("metrics");
assertEquals(0, metrics.size());
- assertNotNull(values.findRecursive("errors", "foo:bar:baz"));
+ assertNotNull(values._get(List.of("errors", "foo:bar:baz"), null));
// unknown metric
resp = new SolrQueryResponse();
@@ -606,7 +607,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
values = resp.getValues();
metrics = (NamedList<?>) values.get("metrics");
assertEquals(0, metrics.size());
- assertNotNull(values.findRecursive("errors", "solr.jetty:unknown:baz"));
+ assertNotNull(values._get(List.of("errors", "solr.jetty:unknown:baz"), null));
handler.close();
}
@@ -630,7 +631,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
// response structure is like in the case of non-key params
Object val =
resp.getValues()
- .findRecursive("metrics", "solr.core.collection1", "QUERY./select.requestTimes");
+ ._get(List.of("metrics", "solr.core.collection1", "QUERY./select.requestTimes"), null);
assertNotNull(val);
assertTrue(val instanceof MapWriter);
Map<String, Object> map = new HashMap<>();
@@ -655,7 +656,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
key2),
resp);
// response structure is like in the case of non-key params
- val = resp.getValues().findRecursive("metrics", "solr.core.collection1");
+ val = resp.getValues()._get(List.of("metrics", "solr.core.collection1"), null);
assertNotNull(val);
Object v = ((SimpleOrderedMap<Object>) val).get("QUERY./select.requestTimes");
assertNotNull(v);
@@ -689,7 +690,7 @@ public class MetricsHandlerTest extends SolrTestCaseJ4 {
MetricsHandler.EXPR_PARAM,
key3),
resp);
- val = resp.getValues().findRecursive("metrics", "solr.core.collection1");
+ val = resp.getValues()._get(List.of("metrics", "solr.core.collection1"), null);
assertNotNull(val);
// for requestTimes only the full set of values from the first expr should be present
assertNotNull(val);
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
index 501a8863f0b..3337e87d057 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedSpellCheckComponentTest.java
@@ -65,7 +65,7 @@ public class DistributedSpellCheckComponentTest extends BaseDistributedSearchTes
NamedList<Object> nl = control.getResponse();
Object explicitNumSuggestExpected =
- nl.findRecursive("responseHeader", "params", "test.expected.suggestions");
+ nl._get(List.of("responseHeader", "params", "test.expected.suggestions"), null);
@SuppressWarnings("unchecked")
NamedList<Object> sc = (NamedList<Object>) nl.get("spellcheck");
diff --git a/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java b/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
index b8203d1581f..fa0886f1122 100644
--- a/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/component/DistributedTermsComponentTest.java
@@ -228,8 +228,8 @@ public class DistributedTermsComponentTest extends BaseDistributedSearchTestCase
// other way is to pass whole response to compare
assertNull(
compare(
- rsp.findRecursive("terms"),
- controlRsp.findRecursive("terms"),
+ rsp._get(List.of("terms"), null),
+ controlRsp._get(List.of("terms"), null),
flags(handle, "terms"),
handle));
}
diff --git a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
index fd7bcfcb9c5..ab8c4cd2512 100644
--- a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
+++ b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java
@@ -36,6 +36,7 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.HighlightParams;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.common.util.NamedList;
import org.apache.solr.handler.component.HighlightComponent;
import org.apache.solr.handler.component.ResponseBuilder;
import org.apache.solr.handler.component.SearchComponent;
@@ -1403,8 +1404,9 @@ public class HighlighterTest extends SolrTestCaseJ4 {
hlComp.prepare(rb);
hlComp.process(rb);
// inspect response
+ NamedList<Object> entries = resp.getValues();
final String[] snippets =
- (String[]) resp.getValues().findRecursive("highlighting", "0", FIELD_NAME);
+ (String[]) entries._get(List.of("highlighting", "0", FIELD_NAME), null);
assertEquals("<em>word|7</em> word|2", snippets[0]);
} finally {
req.close();
diff --git a/solr/core/src/test/org/apache/solr/search/facet/SpatialHeatmapFacetsTest.java b/solr/core/src/test/org/apache/solr/search/facet/SpatialHeatmapFacetsTest.java
index a385eeeb498..6f48e473bca 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/SpatialHeatmapFacetsTest.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/SpatialHeatmapFacetsTest.java
@@ -152,12 +152,12 @@ public class SpatialHeatmapFacetsTest extends BaseDistributedSearchTestCase {
2,
response
.getResponse()
- .findRecursive("facet_counts", "facet_heatmaps", "course", "gridLevel"));
+ ._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null));
assertTrue(
((NamedList<Object>)
response
.getResponse()
- .findRecursive("facet_counts", "facet_heatmaps", "course"))
+ ._get(List.of("facet_counts", "facet_heatmaps", "course"), null))
.indexOf("counts_" + courseFormat, 0)
>= 0);
}
@@ -442,10 +442,10 @@ public class SpatialHeatmapFacetsTest extends BaseDistributedSearchTestCase {
+ "}"));
{
final NamedList<?> q1Res =
- (NamedList<?>) response.getResponse().findRecursive("facets", "q1");
+ (NamedList<?>) response.getResponse()._get(List.of("facets", "q1"), null);
assertEquals("1", q1Res.get("count").toString());
- final NamedList<?> q2Res =
- (NamedList<?>) response.getResponse().findRecursive("facets", "q2");
+ NamedList<Object> entries = response.getResponse();
+ final NamedList<?> q2Res = (NamedList<?>) entries._get(List.of("facets", "q2"), null);
assertEquals("1", q2Res.get("count").toString());
// essentially, these will differ only in the heatmap counts but otherwise will be the same
assertNotNull(compare(q1Res, q2Res, flags, handle));
@@ -507,12 +507,12 @@ public class SpatialHeatmapFacetsTest extends BaseDistributedSearchTestCase {
// classic faceting
final NamedList<?> classicResp =
(NamedList<?>)
- response.getResponse().findRecursive("facet_counts", "facet_heatmaps", FIELD);
+ response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", FIELD), null);
if (classicResp != null) {
return classicResp;
}
// JSON Facet
- return (NamedList<?>) response.getResponse().findRecursive("facets", "f1");
+ return (NamedList<?>) response.getResponse()._get(List.of("facets", "f1"), null);
}
@Test
diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
index b518cfd4ff2..c612b1a9277 100644
--- a/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
+++ b/solr/core/src/test/org/apache/solr/search/facet/TestCloudJSONFacetSKGEquiv.java
@@ -531,7 +531,8 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
// skip past the (implicit) top Facet query to get it's "sub-facets" (the real facets)...
@SuppressWarnings({"unchecked"})
final List<NamedList<Object>> facetDebug =
- (List<NamedList<Object>>) topNamedList.findRecursive("debug", "facet-trace", "sub-facet");
+ (List<NamedList<Object>>)
+ topNamedList._get(List.of("debug", "facet-trace", "sub-facet"), null);
assertNotNull(topNamedList + " ... null facet debug?", facetDebug);
assertFalse(topNamedList + " ... not even one facet debug?", facetDebug.isEmpty());
return facetDebug.get(0);
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
index 717b90dcb6a..c74a9ccbc80 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudHttp2SolrClientTest.java
@@ -680,7 +680,7 @@ public class CloudHttp2SolrClientTest extends SolrCloudTestCase {
}
@SuppressWarnings({"unchecked"})
Map<String, Object> map =
- (Map<String, Object>) resp.findRecursive("solr-mbeans", category, key, "stats");
+ (Map<String, Object>) resp._get(List.of("solr-mbeans", category, key, "stats"), null);
if (map == null) {
return null;
}
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
index ae5beaaa209..ec6fe94d9f0 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
@@ -615,7 +615,7 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
}
@SuppressWarnings({"unchecked"})
Map<String, Object> map =
- (Map<String, Object>) resp.findRecursive("solr-mbeans", category, key, "stats");
+ (Map<String, Object>) resp._get(List.of("solr-mbeans", category, key, "stats"), null);
if (map == null) {
return null;
}
diff --git a/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java b/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java
index 31924a4afbe..cadc88ed890 100644
--- a/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java
+++ b/solr/solrj/src/test/org/apache/solr/common/util/NamedListTest.java
@@ -142,28 +142,28 @@ public class NamedListTest extends SolrTestCase {
nl.add("key3", nl3);
// Simple three-level checks.
- String test1 = (String) nl.findRecursive("key2", "key2b", "key2b2");
+ String test1 = nl._getStr(List.of("key2", "key2b", "key2b2"), null);
assertEquals("value2b2", test1);
- String test2 = (String) nl.findRecursive("key3", "key3a", "key3a3");
+ String test2 = nl._getStr(List.of("key3", "key3a", "key3a3"), null);
assertEquals("value3a3", test2);
// Two-level check.
- String test3 = (String) nl.findRecursive("key3", "key3c");
+ String test3 = nl._getStr(List.of("key3", "key3c"), null);
assertEquals("value3c", test3);
// Checking that invalid values return null.
- String test4 = (String) nl.findRecursive("key3", "key3c", "invalid");
+ String test4 = nl._getStr(List.of("key3", "key3c", "invalid"), null);
assertNull(test4);
- String test5 = (String) nl.findRecursive("key3", "invalid", "invalid");
+ String test5 = nl._getStr(List.of("key3", "invalid", "invalid"), null);
assertNull(test5);
- String test6 = (String) nl.findRecursive("invalid", "key3c");
+ String test6 = nl._getStr(List.of("invalid", "key3c"), null);
assertNull(test6);
// Verify that retrieved NamedList objects have the right type.
- Object test7 = nl.findRecursive("key2", "key2b");
+ Object test7 = nl._get(List.of("key2", "key2b"), null);
assertTrue(test7 instanceof NamedList);
// Integer check.
- int test8 = (Integer) nl.findRecursive("key2", "k2int1");
+ int test8 = (Integer) nl._get(List.of("key2", "k2int1"), null);
assertEquals(5, test8);
// Check that a single argument works the same as get(String).
- String test9 = (String) nl.findRecursive("key1");
+ String test9 = nl._getStr(List.of("key1"), null);
assertEquals("value1", test9);
// enl == explicit nested list
//
@@ -181,15 +181,15 @@ public class NamedListTest extends SolrTestCase {
// Tests that are very similar to the test above, just repeated
// on the explicitly nested object type.
- String enltest1 = (String) enl.findRecursive("key1", "key1a");
+ String enltest1 = enl._getStr(List.of("key1", "key1a"), null);
assertEquals("value1a", enltest1);
- String enltest2 = (String) enl.findRecursive("key1", "key1b");
+ String enltest2 = enl._getStr(List.of("key1", "key1b"), null);
assertEquals("value1b", enltest2);
// Verify that when a null value is stored, the standard get method
// says it is null, then check the recursive method.
Object enltest3 = enl.get("key2");
assertNull(enltest3);
- Object enltest4 = enl.findRecursive("key2");
+ Object enltest4 = enl._get(List.of("key2"), null);
assertNull(enltest4);
}
diff --git a/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.java b/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.java
index a3e8571f8c1..77163549289 100644
--- a/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.java
+++ b/solr/test-framework/src/java/org/apache/solr/handler/BackupStatusChecker.java
@@ -22,6 +22,7 @@ import static org.apache.lucene.tests.util.LuceneTestCase.assertTrue;
import static org.apache.solr.SolrTestCaseJ4.params;
import java.lang.invoke.MethodHandles;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.solr.client.solrj.SolrClient;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
@@ -196,7 +197,7 @@ public final class BackupStatusChecker {
log.info("Checking Status of {}: {}", label, data);
@SuppressWarnings({"unchecked"})
final NamedList<String> backupData =
- (NamedList<String>) data.findRecursive("details", "backup");
+ (NamedList<String>) data._get(List.of("details", "backup"), null);
if (null == backupData) {
// no backup has finished yet
return null;
@@ -273,7 +274,7 @@ public final class BackupStatusChecker {
log.info("Checking Deletion Status of {}: {}", backupName, data);
@SuppressWarnings({"unchecked"})
final NamedList<String> backupData =
- (NamedList<String>) data.findRecursive("details", "backup");
+ (NamedList<String>) data._get(List.of("details", "backup"), null);
if (null == backupData
|| null == backupData.get("status")
|| !backupName.equals(backupData.get("snapshotName"))) {