From 81eed8a5e761ae5084af93445989edcb9c11cf24 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Fri, 16 May 2025 20:19:43 +0530 Subject: [PATCH 01/12] SOLR-17625 NamedList.findRecursive-> _get --- .../java/org/apache/solr/cli/AssertTool.java | 4 +- .../java/org/apache/solr/cli/ConfigTool.java | 4 +- .../org/apache/solr/cli/HealthcheckTool.java | 12 ++++-- .../java/org/apache/solr/cli/StatusTool.java | 23 ++++++---- .../cloud/api/collections/SplitShardCmd.java | 8 +++- .../solr/handler/component/SearchHandler.java | 21 +++++---- .../solr/packagemanager/PackageManager.java | 3 +- .../solr/cloud/CollectionsAPISolrJTest.java | 31 ++++++++----- .../apache/solr/cloud/TestPullReplica.java | 10 +++-- .../solr/cloud/TestPullReplicaWithAuth.java | 10 ++--- .../cloud/TestSkipOverseerOperations.java | 11 ++++- .../apache/solr/cloud/TestTlogReplica.java | 9 ++-- .../TestRequestStatusCollectionAPI.java | 10 +++-- .../FieldAnalysisRequestHandlerTest.java | 5 ++- .../handler/admin/MetricsHandlerTest.java | 34 ++++++++++----- .../DistributedSpellCheckComponentTest.java | 6 ++- .../DistributedTermsComponentTest.java | 9 ++-- .../solr/highlight/HighlighterTest.java | 6 ++- .../facet/SpatialHeatmapFacetsTest.java | 43 ++++++++++--------- .../facet/TestCloudJSONFacetSKGEquiv.java | 5 ++- .../solrj/impl/CloudHttp2SolrClientTest.java | 4 +- .../solrj/impl/CloudSolrClientTest.java | 4 +- .../solr/common/util/NamedListTest.java | 36 ++++++++++------ .../solr/handler/BackupStatusChecker.java | 9 ++-- 24 files changed, 201 insertions(+), 116 deletions(-) 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..e8b0475de32 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.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,8 @@ public int assertSolrNotRunning(String url, String credentials) throws Exception System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeoutMs, TimeUnit.MILLISECONDS); try (SolrClient solrClient = CLIUtils.getSolrClient(url, credentials)) { NamedList response = solrClient.request(new HealthCheckRequest()); - Integer statusCode = (Integer) response.findRecursive("responseHeader", "status"); + Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); + Integer statusCode = (Integer) value; 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..1b819e56b6c 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,8 @@ public void runImpl(CommandLine cli) throws Exception { try (SolrClient solrClient = CLIUtils.getSolrClient(solrUrl, cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION))) { NamedList result = SolrCLI.postJsonToSolr(solrClient, updatePath, jsonBody); - Integer statusCode = (Integer) result.findRecursive("responseHeader", "status"); + Object value1 = result._get(List.of(new String[] {"responseHeader", "status"}), null); + Integer statusCode = (Integer) value1; 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..dadd5ba3b89 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,15 @@ protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) th 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"); + Object value2 = + systemInfo._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); + uptime = SolrCLI.uptime((Long) value2); + Object value1 = + systemInfo._get(List.of(new String[] {"jvm", "memory", "used"}), null); + String usedMemory = (String) value1; + Object value = + systemInfo._get(List.of(new String[] {"jvm", "memory", "total"}), null); + String totalMemory = (String) value; 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..9cf5fdb72a0 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,17 @@ public static Map reportStatus(NamedList info, SolrClien 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"))); - - String usedMemory = (String) info.findRecursive("jvm", "memory", "used"); - String totalMemory = (String) info.findRecursive("jvm", "memory", "total"); + Object value4 = info._get(List.of(new String[] {"lucene", "solr-impl-version"}), null); + status.put("version", value4); + Object value3 = info._get(List.of(new String[] {"jvm", "jmx", "startTime"}), null); + status.put("startTime", value3.toString()); + Object value2 = info._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); + status.put("uptime", SolrCLI.uptime((Long) value2)); + + Object value1 = info._get(List.of(new String[] {"jvm", "memory", "used"}), null); + String usedMemory = (String) value1; + Object value = info._get(List.of(new String[] {"jvm", "memory", "total"}), null); + String totalMemory = (String) value; status.put("memory", usedMemory + " of " + totalMemory); // if this is a Solr in solrcloud mode, gather some basic cluster info @@ -344,11 +349,13 @@ private static Map getCloudStatus(SolrClient solrClient, String // TODO add booleans to request just what we want; not everything NamedList json = solrClient.request(new CollectionAdminRequest.ClusterStatus()); - List liveNodes = (List) json.findRecursive("cluster", "live_nodes"); + Object value1 = json._get(List.of(new String[] {"cluster", "live_nodes"}), null); + List liveNodes = (List) value1; cloudStatus.put("liveNodes", String.valueOf(liveNodes.size())); // TODO get this as a metric from the metrics API instead, or something else. - var collections = (Map) json.findRecursive("cluster", "collections"); + Object value = json._get(List.of(new String[] {"cluster", "collections"}), null); + var collections = (Map) value; 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..651d775fe4d 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,18 @@ public static void checkDiskSpace( SolrRequest.METHOD.GET, "/admin/metrics", SolrRequest.SolrRequestType.ADMIN, params) .process(cloudManager.getSolrClient()); - Number size = (Number) rsp.getResponse().findRecursive("metrics", indexSizeMetricName); + NamedList entries1 = rsp.getResponse(); + Object value1 = entries1._get(List.of(new String[] {"metrics", indexSizeMetricName}), null); + Number size = (Number) value1; 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); + NamedList entries = rsp.getResponse(); + Object value = entries._get(List.of(new String[] {"metrics", freeDiskSpaceMetricName}), null); + Number freeSize = (Number) value; 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..30d8b40a0fa 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,20 @@ private void processComponents( if (resp == null) { return false; } - Object recursive = resp.findRecursive("responseHeader", "partialResults"); + Object value1 = + resp._get( + List.of(new String[] {"responseHeader", "partialResults"}), null); + Object recursive = value1; if (recursive != null) { - Object message = - "[Shard:" - + response.getShardAddress() - + "]" - + resp.findRecursive( - "responseHeader", - RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY); + Object value = + resp._get( + List.of( + new String[] { + "responseHeader", + RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY + }), + null); + Object message = "[Shard:" + response.getShardAddress() + "]" + value; 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..b80f1cb2ce4 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,8 @@ public Map getPackagesDeployedAsClusterLevelPlugins NamedList response = solrClient.request( new GenericV2SolrRequest(SolrRequest.METHOD.GET, PackageUtils.CLUSTERPROPS_PATH)); - Integer statusCode = (Integer) response.findRecursive("responseHeader", "status"); + Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); + Integer statusCode = (Integer) value; 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..54a487685a4 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java @@ -620,19 +620,29 @@ public void testColStatus() throws Exception { CollectionAdminResponse rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); assertNotNull(rsp.getResponse().get(collectionName)); - assertNotNull(rsp.getResponse().findRecursive(collectionName, "properties")); - final var collPropMap = - (Map) rsp.getResponse().findRecursive(collectionName, "properties"); + NamedList entries5 = rsp.getResponse(); + Object value5 = entries5._get(List.of(new String[] {collectionName, "properties"}), null); + assertNotNull(value5); + NamedList entries4 = rsp.getResponse(); + Object value4 = entries4._get(List.of(new String[] {collectionName, "properties"}), null); + final var collPropMap = (Map) value4; assertEquals("conf2", collPropMap.get("configName")); assertEquals(2L, collPropMap.get("nrtReplicas")); assertEquals("0", collPropMap.get("tlogReplicas")); assertEquals("0", collPropMap.get("pullReplicas")); - assertEquals( - 2, ((NamedList) rsp.getResponse().findRecursive(collectionName, "shards")).size()); - assertNotNull(rsp.getResponse().findRecursive(collectionName, "shards", "shard1", "leader")); + NamedList entries3 = rsp.getResponse(); + Object value3 = entries3._get(List.of(new String[] {collectionName, "shards"}), null); + assertEquals(2, ((NamedList) value3).size()); + NamedList entries2 = rsp.getResponse(); + Object value2 = + entries2._get(List.of(new String[] {collectionName, "shards", "shard1", "leader"}), null); + assertNotNull(value2); // Ensure more advanced info is not returned - assertNull( - rsp.getResponse().findRecursive(collectionName, "shards", "shard1", "leader", "segInfos")); + NamedList entries1 = rsp.getResponse(); + Object value1 = + entries1._get( + List.of(new String[] {collectionName, "shards", "shard1", "leader", "segInfos"}), null); + assertNull(value1); // Returns segment metadata iff requested req = CollectionAdminRequest.collectionStatus(collectionName); @@ -687,9 +697,10 @@ public void testColStatus() throws Exception { req.setWithSizeInfo(true); rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); + NamedList entries = rsp.getResponse(); + Object value = entries._get(List.of(new String[] {collectionName, "schemaNonCompliant"}), null); @SuppressWarnings({"unchecked"}) - List nonCompliant = - (List) rsp.getResponse().findRecursive(collectionName, "schemaNonCompliant"); + List nonCompliant = (List) value; 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..2212ba5e264 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java @@ -54,6 +54,7 @@ import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.cloud.ZkStateReader; +import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.TimeSource; import org.apache.solr.core.CoreDescriptor; import org.apache.solr.core.SolrCore; @@ -315,12 +316,13 @@ public void testAddDocs() throws Exception { SolrQuery req = new SolrQuery("qt", "/admin/plugins", "stats", "true"); QueryResponse statsResponse = pullReplicaClient.query(req); // The adds gauge metric should be null for pull replicas since they don't process adds + NamedList entries = (statsResponse.getResponse()); + Object value = + entries._get( + List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); assertNull( "Replicas shouldn't process the add document request: " + statsResponse, - ((Map) - (statsResponse.getResponse()) - .findRecursive("plugins", "UPDATE", "updateHandler", "stats")) - .get("UPDATE.updateHandler.adds")); + ((Map) value).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..20d849f2e96 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.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 void testPKIAuthWorksForPullReplication() throws Exception { @SuppressWarnings("unchecked") private Object getUpdateHandlerMetric(QueryResponse statsResponse, String metric) { - return ((Map) - statsResponse - .getResponse() - .findRecursive("plugins", "UPDATE", "updateHandler", "stats")) - .get(metric); + NamedList entries = statsResponse.getResponse(); + Object value = + entries._get(List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); + return ((Map) value).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..b3ac36f7517 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.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,10 @@ public boolean matches(SortedSet oldLiveNodes, SortedSet newLive *

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 entries = resp.getResponse(); + Object value = + entries._get(List.of(new String[] {"overseer_operations", "leader", "requests"}), null); + return (int) value; } /** @@ -245,7 +249,10 @@ private int getNumLeaderOperations(CollectionAdminResponse resp) { * 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 entries = resp.getResponse(); + Object value = + entries._get(List.of(new String[] {"overseer_operations", "state", "requests"}), null); + return (int) value; } 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..006034d9349 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java @@ -286,16 +286,17 @@ public void testAddDocs() throws Exception { "qt", "/admin/plugins", "stats", "true"); QueryResponse statsResponse = tlogReplicaClient.query(req); + NamedList entries = (statsResponse.getResponse()); + Object value = + entries._get( + List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); assertEquals( "Append replicas should recive all updates. Replica: " + r + ", response: " + statsResponse, 1L, - ((Map) - (statsResponse.getResponse()) - .findRecursive("plugins", "UPDATE", "updateHandler", "stats")) - .get("UPDATE.updateHandler.cumulativeAdds.count")); + ((Map) value).get("UPDATE.updateHandler.cumulativeAdds.count")); break; } catch (AssertionError e) { if (t.hasTimedOut()) { 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..773d397150b 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 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,8 @@ public void test() { NamedList createResponse = null; try { createResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - message = (String) createResponse.findRecursive("status", "msg"); + Object value = createResponse._get(List.of(new String[] {"status", "msg"}), null); + message = (String) value; } catch (SolrServerException | IOException e) { log.error("error sending request", e); } @@ -122,7 +124,8 @@ public void test() { NamedList splitResponse = null; try { splitResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - message = (String) splitResponse.findRecursive("status", "msg"); + Object value = splitResponse._get(List.of(new String[] {"status", "msg"}), null); + message = (String) value; } catch (SolrServerException | IOException e) { log.error("error sending request", e); } @@ -154,7 +157,8 @@ public void test() { try { NamedList response = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - message = (String) response.findRecursive("status", "msg"); + Object value = response._get(List.of(new String[] {"status", "msg"}), null); + message = (String) value; } 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..8798d652da7 100644 --- a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java @@ -798,9 +798,10 @@ public TokenStream create(TokenStream input) { @SuppressWarnings({"rawtypes"}) NamedList result = handler.analyzeValues(request, fieldType, "fieldNameUnused"); // just test that we see "900" in the flags attribute here + Object value = + result._get(List.of(new String[] {"index", CustomTokenFilter.class.getName()}), null); @SuppressWarnings({"unchecked", "rawtypes"}) - List tokenInfoList = - (List) result.findRecursive("index", CustomTokenFilter.class.getName()); + List tokenInfoList = (List) value; // '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..118831f0400 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.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,8 @@ public void testKeyMetrics() throws Exception { key1), resp); NamedList values = resp.getValues(); - Object val = values.findRecursive("metrics", key1); + Object value4 = values._get(List.of(new String[] {"metrics", key1}), null); + Object val = value4; assertNotNull(val); assertTrue(val instanceof MapWriter); assertTrue(((MapWriter) val)._size() >= 2); @@ -573,8 +575,10 @@ public void testKeyMetrics() throws Exception { 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")); + Object value3 = values._get(List.of(new String[] {"errors", "foo"}), null); + assertNotNull(value3); + Object value2 = values._get(List.of(new String[] {"errors", "foo:bar:baz:xyz"}), null); + assertNotNull(value2); // unknown registry resp = new SolrQueryResponse(); @@ -590,7 +594,8 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - assertNotNull(values.findRecursive("errors", "foo:bar:baz")); + Object value1 = values._get(List.of(new String[] {"errors", "foo:bar:baz"}), null); + assertNotNull(value1); // unknown metric resp = new SolrQueryResponse(); @@ -606,7 +611,8 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - assertNotNull(values.findRecursive("errors", "solr.jetty:unknown:baz")); + Object value = values._get(List.of(new String[] {"errors", "solr.jetty:unknown:baz"}), null); + assertNotNull(value); handler.close(); } @@ -628,9 +634,13 @@ public void testExprMetrics() throws Exception { key1), resp); // response structure is like in the case of non-key params - Object val = - resp.getValues() - .findRecursive("metrics", "solr.core.collection1", "QUERY./select.requestTimes"); + NamedList entries2 = resp.getValues(); + Object value2 = + entries2._get( + List.of( + new String[] {"metrics", "solr.core.collection1", "QUERY./select.requestTimes"}), + null); + Object val = value2; assertNotNull(val); assertTrue(val instanceof MapWriter); Map map = new HashMap<>(); @@ -655,7 +665,9 @@ public void testExprMetrics() throws Exception { key2), resp); // response structure is like in the case of non-key params - val = resp.getValues().findRecursive("metrics", "solr.core.collection1"); + NamedList entries1 = resp.getValues(); + Object value1 = entries1._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); + val = value1; assertNotNull(val); Object v = ((SimpleOrderedMap) val).get("QUERY./select.requestTimes"); assertNotNull(v); @@ -689,7 +701,9 @@ public void testExprMetrics() throws Exception { MetricsHandler.EXPR_PARAM, key3), resp); - val = resp.getValues().findRecursive("metrics", "solr.core.collection1"); + NamedList entries = resp.getValues(); + Object value = entries._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); + val = value; 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..a9a3fe5e687 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 @@ -64,8 +64,10 @@ private void q(Object... q) throws Exception { public void validateControlData(QueryResponse control) { NamedList nl = control.getResponse(); - Object explicitNumSuggestExpected = - nl.findRecursive("responseHeader", "params", "test.expected.suggestions"); + Object value = + nl._get( + List.of(new String[] {"responseHeader", "params", "test.expected.suggestions"}), null); + Object explicitNumSuggestExpected = value; @SuppressWarnings("unchecked") NamedList sc = (NamedList) 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..6dcb360850e 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 @@ -226,12 +226,9 @@ protected QueryResponse query(boolean setDistribParams, SolrParams p) throws Exc // flags needs to be called here since only terms response is passed to compare // other way is to pass whole response to compare - assertNull( - compare( - rsp.findRecursive("terms"), - controlRsp.findRecursive("terms"), - flags(handle, "terms"), - handle)); + Object value = controlRsp._get(List.of(new String[] {"terms"}), null); + Object value1 = rsp._get(List.of(new String[] {"terms"}), null); + assertNull(compare(value1, value, flags(handle, "terms"), handle)); } return queryResponse; } 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..f154aca4e4d 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.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 void payloadFilteringSpanQuery() throws IOException { hlComp.prepare(rb); hlComp.process(rb); // inspect response - final String[] snippets = - (String[]) resp.getValues().findRecursive("highlighting", "0", FIELD_NAME); + NamedList entries = resp.getValues(); + Object value = entries._get(List.of(new String[] {"highlighting", "0", FIELD_NAME}), null); + final String[] snippets = (String[]) value; assertEquals("word|7 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..bf2ce70e626 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 @@ -148,18 +148,16 @@ public void testClassicFacets() throws Exception { // AKA SimpleFacets + FIELD); final QueryResponse response = query(params); assertEquals(6, getHmObj(response).get("gridLevel")); // same test as above - assertEquals( - 2, - response - .getResponse() - .findRecursive("facet_counts", "facet_heatmaps", "course", "gridLevel")); - assertTrue( - ((NamedList) - response - .getResponse() - .findRecursive("facet_counts", "facet_heatmaps", "course")) - .indexOf("counts_" + courseFormat, 0) - >= 0); + NamedList entries1 = response.getResponse(); + Object value1 = + entries1._get( + List.of(new String[] {"facet_counts", "facet_heatmaps", "course", "gridLevel"}), + null); + assertEquals(2, value1); + NamedList entries = response.getResponse(); + Object value = + entries._get(List.of(new String[] {"facet_counts", "facet_heatmaps", "course"}), null); + assertTrue(((NamedList) value).indexOf("counts_" + courseFormat, 0) >= 0); } // ------ Index data @@ -441,11 +439,13 @@ public void testJsonFacets() throws Exception { + " } " + "}")); { - final NamedList q1Res = - (NamedList) response.getResponse().findRecursive("facets", "q1"); + NamedList entries1 = response.getResponse(); + Object value1 = entries1._get(List.of(new String[] {"facets", "q1"}), null); + final NamedList q1Res = (NamedList) value1; assertEquals("1", q1Res.get("count").toString()); - final NamedList q2Res = - (NamedList) response.getResponse().findRecursive("facets", "q2"); + NamedList entries = response.getResponse(); + Object value = entries._get(List.of(new String[] {"facets", "q2"}), null); + final NamedList q2Res = (NamedList) value; 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)); @@ -505,14 +505,17 @@ public void testJsonFacets() throws Exception { private NamedList getHmObj(QueryResponse response) { // classic faceting - final NamedList classicResp = - (NamedList) - response.getResponse().findRecursive("facet_counts", "facet_heatmaps", FIELD); + NamedList entries1 = response.getResponse(); + Object value1 = + entries1._get(List.of(new String[] {"facet_counts", "facet_heatmaps", FIELD}), null); + final NamedList classicResp = (NamedList) value1; if (classicResp != null) { return classicResp; } // JSON Facet - return (NamedList) response.getResponse().findRecursive("facets", "f1"); + NamedList entries = response.getResponse(); + Object value = entries._get(List.of(new String[] {"facets", "f1"}), null); + return (NamedList) value; } @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..31d5ac03c01 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 @@ -529,9 +529,10 @@ private NamedList getFacetDebug(final SolrParams params) { assertNotNull(params + " is null topNamedList?", topNamedList); // skip past the (implicit) top Facet query to get it's "sub-facets" (the real facets)... + Object value = + topNamedList._get(List.of(new String[] {"debug", "facet-trace", "sub-facet"}), null); @SuppressWarnings({"unchecked"}) - final List> facetDebug = - (List>) topNamedList.findRecursive("debug", "facet-trace", "sub-facet"); + final List> facetDebug = (List>) value; 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..e64f077a8b4 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 @@ -678,9 +678,9 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } + Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); @SuppressWarnings({"unchecked"}) - Map map = - (Map) resp.findRecursive("solr-mbeans", category, key, "stats"); + Map map = (Map) value; 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..bb195f25add 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 @@ -613,9 +613,9 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } + Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); @SuppressWarnings({"unchecked"}) - Map map = - (Map) resp.findRecursive("solr-mbeans", category, key, "stats"); + Map map = (Map) value; 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..5ce8b749868 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,37 @@ public void testRecursive() { nl.add("key3", nl3); // Simple three-level checks. - String test1 = (String) nl.findRecursive("key2", "key2b", "key2b2"); + Object value11 = nl._get(List.of(new String[] {"key2", "key2b", "key2b2"}), null); + String test1 = (String) value11; assertEquals("value2b2", test1); - String test2 = (String) nl.findRecursive("key3", "key3a", "key3a3"); + Object value10 = nl._get(List.of(new String[] {"key3", "key3a", "key3a3"}), null); + String test2 = (String) value10; assertEquals("value3a3", test2); // Two-level check. - String test3 = (String) nl.findRecursive("key3", "key3c"); + Object value9 = nl._get(List.of(new String[] {"key3", "key3c"}), null); + String test3 = (String) value9; assertEquals("value3c", test3); // Checking that invalid values return null. - String test4 = (String) nl.findRecursive("key3", "key3c", "invalid"); + Object value8 = nl._get(List.of(new String[] {"key3", "key3c", "invalid"}), null); + String test4 = (String) value8; assertNull(test4); - String test5 = (String) nl.findRecursive("key3", "invalid", "invalid"); + Object value7 = nl._get(List.of(new String[] {"key3", "invalid", "invalid"}), null); + String test5 = (String) value7; assertNull(test5); - String test6 = (String) nl.findRecursive("invalid", "key3c"); + Object value6 = nl._get(List.of(new String[] {"invalid", "key3c"}), null); + String test6 = (String) value6; assertNull(test6); // Verify that retrieved NamedList objects have the right type. - Object test7 = nl.findRecursive("key2", "key2b"); + Object value5 = nl._get(List.of(new String[] {"key2", "key2b"}), null); + Object test7 = value5; assertTrue(test7 instanceof NamedList); // Integer check. - int test8 = (Integer) nl.findRecursive("key2", "k2int1"); + Object value4 = nl._get(List.of(new String[] {"key2", "k2int1"}), null); + int test8 = (Integer) value4; assertEquals(5, test8); // Check that a single argument works the same as get(String). - String test9 = (String) nl.findRecursive("key1"); + Object value3 = nl._get(List.of(new String[] {"key1"}), null); + String test9 = (String) value3; assertEquals("value1", test9); // enl == explicit nested list // @@ -181,15 +190,18 @@ public void testRecursive() { // Tests that are very similar to the test above, just repeated // on the explicitly nested object type. - String enltest1 = (String) enl.findRecursive("key1", "key1a"); + Object value2 = enl._get(List.of(new String[] {"key1", "key1a"}), null); + String enltest1 = (String) value2; assertEquals("value1a", enltest1); - String enltest2 = (String) enl.findRecursive("key1", "key1b"); + Object value1 = enl._get(List.of(new String[] {"key1", "key1b"}), null); + String enltest2 = (String) value1; 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 value = enl._get(List.of(new String[] {"key2"}), null); + Object enltest4 = value; 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..dcf1a127bd0 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.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; @@ -194,9 +195,9 @@ private String _checkBackupSuccess(final String backupName) throws Exception { .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Status of {}: {}", label, data); + Object value = data._get(List.of(new String[] {"details", "backup"}), null); @SuppressWarnings({"unchecked"}) - final NamedList backupData = - (NamedList) data.findRecursive("details", "backup"); + final NamedList backupData = (NamedList) value; if (null == backupData) { // no backup has finished yet return null; @@ -271,9 +272,9 @@ public boolean checkBackupDeletionSuccess(final String backupName) throws Except .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Deletion Status of {}: {}", backupName, data); + Object value = data._get(List.of(new String[] {"details", "backup"}), null); @SuppressWarnings({"unchecked"}) - final NamedList backupData = - (NamedList) data.findRecursive("details", "backup"); + final NamedList backupData = (NamedList) value; if (null == backupData || null == backupData.get("status") || !backupName.equals(backupData.get("snapshotName"))) { From 109d8ff93f79699738890422f1439ee39be3b6b6 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Sat, 17 May 2025 14:44:55 -0400 Subject: [PATCH 02/12] Replace List.of(array) direct arguments --- .../java/org/apache/solr/cli/AssertTool.java | 2 +- .../java/org/apache/solr/cli/ConfigTool.java | 2 +- .../org/apache/solr/cli/HealthcheckTool.java | 9 +++---- .../java/org/apache/solr/cli/StatusTool.java | 14 +++++------ .../cloud/api/collections/SplitShardCmd.java | 4 ++-- .../solr/handler/component/SearchHandler.java | 9 +++---- .../solr/packagemanager/PackageManager.java | 2 +- .../solr/cloud/CollectionsAPISolrJTest.java | 14 +++++------ .../apache/solr/cloud/TestPullReplica.java | 4 +--- .../solr/cloud/TestPullReplicaWithAuth.java | 3 +-- .../cloud/TestSkipOverseerOperations.java | 6 ++--- .../apache/solr/cloud/TestTlogReplica.java | 3 +-- .../TestRequestStatusCollectionAPI.java | 6 ++--- .../FieldAnalysisRequestHandlerTest.java | 3 +-- .../handler/admin/MetricsHandlerTest.java | 18 +++++++------- .../DistributedSpellCheckComponentTest.java | 4 +--- .../DistributedTermsComponentTest.java | 4 ++-- .../solr/highlight/HighlighterTest.java | 2 +- .../facet/SpatialHeatmapFacetsTest.java | 16 +++++-------- .../facet/TestCloudJSONFacetSKGEquiv.java | 3 +-- .../solrj/impl/CloudHttp2SolrClientTest.java | 2 +- .../solrj/impl/CloudSolrClientTest.java | 2 +- .../solr/common/util/NamedListTest.java | 24 +++++++++---------- .../solr/handler/BackupStatusChecker.java | 4 ++-- 24 files changed, 68 insertions(+), 92 deletions(-) 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 e8b0475de32..446c70cfbac 100644 --- a/solr/core/src/java/org/apache/solr/cli/AssertTool.java +++ b/solr/core/src/java/org/apache/solr/cli/AssertTool.java @@ -281,7 +281,7 @@ public int assertSolrNotRunning(String url, String credentials) throws Exception System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeoutMs, TimeUnit.MILLISECONDS); try (SolrClient solrClient = CLIUtils.getSolrClient(url, credentials)) { NamedList response = solrClient.request(new HealthCheckRequest()); - Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); + Object value = response._get(List.of("responseHeader", "status"), null); Integer statusCode = (Integer) value; CLIUtils.checkCodeForAuthError(statusCode); } catch (IOException | SolrServerException 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 1b819e56b6c..096d0ce7b8f 100644 --- a/solr/core/src/java/org/apache/solr/cli/ConfigTool.java +++ b/solr/core/src/java/org/apache/solr/cli/ConfigTool.java @@ -125,7 +125,7 @@ public void runImpl(CommandLine cli) throws Exception { try (SolrClient solrClient = CLIUtils.getSolrClient(solrUrl, cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION))) { NamedList result = SolrCLI.postJsonToSolr(solrClient, updatePath, jsonBody); - Object value1 = result._get(List.of(new String[] {"responseHeader", "status"}), null); + Object value1 = result._get(List.of("responseHeader", "status"), null); Integer statusCode = (Integer) value1; if (statusCode == 0) { if (value != null) { 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 dadd5ba3b89..0a537116dfd 100644 --- a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java +++ b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java @@ -173,14 +173,11 @@ protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) th solrClient.request( new GenericSolrRequest( SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH)); - Object value2 = - systemInfo._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); + Object value2 = systemInfo._get(List.of("jvm", "jmx", "upTimeMS"), null); uptime = SolrCLI.uptime((Long) value2); - Object value1 = - systemInfo._get(List.of(new String[] {"jvm", "memory", "used"}), null); + Object value1 = systemInfo._get(List.of("jvm", "memory", "used"), null); String usedMemory = (String) value1; - Object value = - systemInfo._get(List.of(new String[] {"jvm", "memory", "total"}), null); + Object value = systemInfo._get(List.of("jvm", "memory", "total"), null); String totalMemory = (String) value; 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 9cf5fdb72a0..4448ddb8ec1 100644 --- a/solr/core/src/java/org/apache/solr/cli/StatusTool.java +++ b/solr/core/src/java/org/apache/solr/cli/StatusTool.java @@ -314,16 +314,16 @@ public static Map reportStatus(NamedList info, SolrClien String solrHome = (String) info.get("solr_home"); status.put("solr_home", solrHome != null ? solrHome : "?"); - Object value4 = info._get(List.of(new String[] {"lucene", "solr-impl-version"}), null); + Object value4 = info._get(List.of("lucene", "solr-impl-version"), null); status.put("version", value4); - Object value3 = info._get(List.of(new String[] {"jvm", "jmx", "startTime"}), null); + Object value3 = info._get(List.of("jvm", "jmx", "startTime"), null); status.put("startTime", value3.toString()); - Object value2 = info._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); + Object value2 = info._get(List.of("jvm", "jmx", "upTimeMS"), null); status.put("uptime", SolrCLI.uptime((Long) value2)); - Object value1 = info._get(List.of(new String[] {"jvm", "memory", "used"}), null); + Object value1 = info._get(List.of("jvm", "memory", "used"), null); String usedMemory = (String) value1; - Object value = info._get(List.of(new String[] {"jvm", "memory", "total"}), null); + Object value = info._get(List.of("jvm", "memory", "total"), null); String totalMemory = (String) value; status.put("memory", usedMemory + " of " + totalMemory); @@ -349,12 +349,12 @@ private static Map getCloudStatus(SolrClient solrClient, String // TODO add booleans to request just what we want; not everything NamedList json = solrClient.request(new CollectionAdminRequest.ClusterStatus()); - Object value1 = json._get(List.of(new String[] {"cluster", "live_nodes"}), null); + Object value1 = json._get(List.of("cluster", "live_nodes"), null); List liveNodes = (List) value1; cloudStatus.put("liveNodes", String.valueOf(liveNodes.size())); // TODO get this as a metric from the metrics API instead, or something else. - Object value = json._get(List.of(new String[] {"cluster", "collections"}), null); + Object value = json._get(List.of("cluster", "collections"), null); var collections = (Map) value; cloudStatus.put("collections", String.valueOf(collections.size())); 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 651d775fe4d..ea0c4b221b9 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 @@ -863,7 +863,7 @@ public static void checkDiskSpace( .process(cloudManager.getSolrClient()); NamedList entries1 = rsp.getResponse(); - Object value1 = entries1._get(List.of(new String[] {"metrics", indexSizeMetricName}), null); + Object value1 = entries1._get(List.of("metrics", indexSizeMetricName), null); Number size = (Number) value1; if (size == null) { log.warn("cannot verify information for parent shard leader"); @@ -872,7 +872,7 @@ public static void checkDiskSpace( double indexSize = size.doubleValue(); NamedList entries = rsp.getResponse(); - Object value = entries._get(List.of(new String[] {"metrics", freeDiskSpaceMetricName}), null); + Object value = entries._get(List.of("metrics", freeDiskSpaceMetricName), null); Number freeSize = (Number) value; if (freeSize == null) { log.warn("missing node disk space information for parent shard leader"); 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 30d8b40a0fa..80604807f24 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 @@ -610,17 +610,14 @@ private void processComponents( return false; } Object value1 = - resp._get( - List.of(new String[] {"responseHeader", "partialResults"}), null); + resp._get(List.of("responseHeader", "partialResults"), null); Object recursive = value1; if (recursive != null) { Object value = resp._get( List.of( - new String[] { - "responseHeader", - RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY - }), + "responseHeader", + RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY), null); Object message = "[Shard:" + response.getShardAddress() + "]" + value; detailMesg.compareAndSet(null, message); // first one, ingore rest 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 b80f1cb2ce4..7879465100b 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 Map getPackagesDeployedAsClusterLevelPlugins NamedList response = solrClient.request( new GenericV2SolrRequest(SolrRequest.METHOD.GET, PackageUtils.CLUSTERPROPS_PATH)); - Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); + Object value = response._get(List.of("responseHeader", "status"), null); Integer statusCode = (Integer) value; if (statusCode == null || statusCode == ErrorCode.NOT_FOUND.code) { // Cluster props doesn't exist, that means there are no cluster level plugins installed. 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 54a487685a4..6c4fce82ed2 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java @@ -621,27 +621,25 @@ public void testColStatus() throws Exception { assertEquals(0, rsp.getStatus()); assertNotNull(rsp.getResponse().get(collectionName)); NamedList entries5 = rsp.getResponse(); - Object value5 = entries5._get(List.of(new String[] {collectionName, "properties"}), null); + Object value5 = entries5._get(List.of(collectionName, "properties"), null); assertNotNull(value5); NamedList entries4 = rsp.getResponse(); - Object value4 = entries4._get(List.of(new String[] {collectionName, "properties"}), null); + Object value4 = entries4._get(List.of(collectionName, "properties"), null); final var collPropMap = (Map) value4; assertEquals("conf2", collPropMap.get("configName")); assertEquals(2L, collPropMap.get("nrtReplicas")); assertEquals("0", collPropMap.get("tlogReplicas")); assertEquals("0", collPropMap.get("pullReplicas")); NamedList entries3 = rsp.getResponse(); - Object value3 = entries3._get(List.of(new String[] {collectionName, "shards"}), null); + Object value3 = entries3._get(List.of(collectionName, "shards"), null); assertEquals(2, ((NamedList) value3).size()); NamedList entries2 = rsp.getResponse(); - Object value2 = - entries2._get(List.of(new String[] {collectionName, "shards", "shard1", "leader"}), null); + Object value2 = entries2._get(List.of(collectionName, "shards", "shard1", "leader"), null); assertNotNull(value2); // Ensure more advanced info is not returned NamedList entries1 = rsp.getResponse(); Object value1 = - entries1._get( - List.of(new String[] {collectionName, "shards", "shard1", "leader", "segInfos"}), null); + entries1._get(List.of(collectionName, "shards", "shard1", "leader", "segInfos"), null); assertNull(value1); // Returns segment metadata iff requested @@ -698,7 +696,7 @@ public void testColStatus() throws Exception { rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); NamedList entries = rsp.getResponse(); - Object value = entries._get(List.of(new String[] {collectionName, "schemaNonCompliant"}), null); + Object value = entries._get(List.of(collectionName, "schemaNonCompliant"), null); @SuppressWarnings({"unchecked"}) List nonCompliant = (List) value; assertEquals(nonCompliant.toString(), 1, nonCompliant.size()); 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 2212ba5e264..2bad973edb1 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java @@ -317,9 +317,7 @@ public void testAddDocs() throws Exception { QueryResponse statsResponse = pullReplicaClient.query(req); // The adds gauge metric should be null for pull replicas since they don't process adds NamedList entries = (statsResponse.getResponse()); - Object value = - entries._get( - List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); + Object value = entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null); assertNull( "Replicas shouldn't process the add document request: " + statsResponse, ((Map) value).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 20d849f2e96..f818bcc8327 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java @@ -155,8 +155,7 @@ public void testPKIAuthWorksForPullReplication() throws Exception { @SuppressWarnings("unchecked") private Object getUpdateHandlerMetric(QueryResponse statsResponse, String metric) { NamedList entries = statsResponse.getResponse(); - Object value = - entries._get(List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); + Object value = entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null); return ((Map) value).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 b3ac36f7517..707146600fb 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java @@ -239,8 +239,7 @@ public boolean matches(SortedSet oldLiveNodes, SortedSet newLive */ private int getNumLeaderOperations(CollectionAdminResponse resp) { NamedList entries = resp.getResponse(); - Object value = - entries._get(List.of(new String[] {"overseer_operations", "leader", "requests"}), null); + Object value = entries._get(List.of("overseer_operations", "leader", "requests"), null); return (int) value; } @@ -250,8 +249,7 @@ private int getNumLeaderOperations(CollectionAdminResponse resp) { */ private int getNumStateOperations(CollectionAdminResponse resp) { NamedList entries = resp.getResponse(); - Object value = - entries._get(List.of(new String[] {"overseer_operations", "state", "requests"}), null); + Object value = entries._get(List.of("overseer_operations", "state", "requests"), null); return (int) value; } 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 006034d9349..767c4a72b42 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java @@ -288,8 +288,7 @@ public void testAddDocs() throws Exception { QueryResponse statsResponse = tlogReplicaClient.query(req); NamedList entries = (statsResponse.getResponse()); Object value = - entries._get( - List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); + entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null); assertEquals( "Append replicas should recive all updates. Replica: " + r 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 773d397150b..e1023c863bc 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 @@ -80,7 +80,7 @@ public void test() { NamedList createResponse = null; try { createResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = createResponse._get(List.of(new String[] {"status", "msg"}), null); + Object value = createResponse._get(List.of("status", "msg"), null); message = (String) value; } catch (SolrServerException | IOException e) { log.error("error sending request", e); @@ -124,7 +124,7 @@ public void test() { NamedList splitResponse = null; try { splitResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = splitResponse._get(List.of(new String[] {"status", "msg"}), null); + Object value = splitResponse._get(List.of("status", "msg"), null); message = (String) value; } catch (SolrServerException | IOException e) { log.error("error sending request", e); @@ -157,7 +157,7 @@ public void test() { try { NamedList response = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = response._get(List.of(new String[] {"status", "msg"}), null); + Object value = response._get(List.of("status", "msg"), null); message = (String) value; } 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 8798d652da7..57890aaf9ca 100644 --- a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java @@ -798,8 +798,7 @@ public TokenStream create(TokenStream input) { @SuppressWarnings({"rawtypes"}) NamedList result = handler.analyzeValues(request, fieldType, "fieldNameUnused"); // just test that we see "900" in the flags attribute here - Object value = - result._get(List.of(new String[] {"index", CustomTokenFilter.class.getName()}), null); + Object value = result._get(List.of("index", CustomTokenFilter.class.getName()), null); @SuppressWarnings({"unchecked", "rawtypes"}) List tokenInfoList = (List) value; // '1' from CustomTokenFilter plus 900 from CustomFlagsAttributeImpl. 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 118831f0400..1e70b20e304 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 @@ -480,7 +480,7 @@ public void testKeyMetrics() throws Exception { key1), resp); NamedList values = resp.getValues(); - Object value4 = values._get(List.of(new String[] {"metrics", key1}), null); + Object value4 = values._get(List.of("metrics", key1), null); Object val = value4; assertNotNull(val); assertTrue(val instanceof MapWriter); @@ -575,9 +575,9 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); NamedList metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value3 = values._get(List.of(new String[] {"errors", "foo"}), null); + Object value3 = values._get(List.of("errors", "foo"), null); assertNotNull(value3); - Object value2 = values._get(List.of(new String[] {"errors", "foo:bar:baz:xyz"}), null); + Object value2 = values._get(List.of("errors", "foo:bar:baz:xyz"), null); assertNotNull(value2); // unknown registry @@ -594,7 +594,7 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value1 = values._get(List.of(new String[] {"errors", "foo:bar:baz"}), null); + Object value1 = values._get(List.of("errors", "foo:bar:baz"), null); assertNotNull(value1); // unknown metric @@ -611,7 +611,7 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value = values._get(List.of(new String[] {"errors", "solr.jetty:unknown:baz"}), null); + Object value = values._get(List.of("errors", "solr.jetty:unknown:baz"), null); assertNotNull(value); handler.close(); @@ -637,9 +637,7 @@ public void testExprMetrics() throws Exception { NamedList entries2 = resp.getValues(); Object value2 = entries2._get( - List.of( - new String[] {"metrics", "solr.core.collection1", "QUERY./select.requestTimes"}), - null); + List.of("metrics", "solr.core.collection1", "QUERY./select.requestTimes"), null); Object val = value2; assertNotNull(val); assertTrue(val instanceof MapWriter); @@ -666,7 +664,7 @@ public void testExprMetrics() throws Exception { resp); // response structure is like in the case of non-key params NamedList entries1 = resp.getValues(); - Object value1 = entries1._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); + Object value1 = entries1._get(List.of("metrics", "solr.core.collection1"), null); val = value1; assertNotNull(val); Object v = ((SimpleOrderedMap) val).get("QUERY./select.requestTimes"); @@ -702,7 +700,7 @@ public void testExprMetrics() throws Exception { key3), resp); NamedList entries = resp.getValues(); - Object value = entries._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); + Object value = entries._get(List.of("metrics", "solr.core.collection1"), null); val = value; assertNotNull(val); // for requestTimes only the full set of values from the first expr should be present 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 a9a3fe5e687..dfb314acf63 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 @@ -64,9 +64,7 @@ private void q(Object... q) throws Exception { public void validateControlData(QueryResponse control) { NamedList nl = control.getResponse(); - Object value = - nl._get( - List.of(new String[] {"responseHeader", "params", "test.expected.suggestions"}), null); + Object value = nl._get(List.of("responseHeader", "params", "test.expected.suggestions"), null); Object explicitNumSuggestExpected = value; @SuppressWarnings("unchecked") 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 6dcb360850e..c40b00cadbf 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 @@ -226,8 +226,8 @@ protected QueryResponse query(boolean setDistribParams, SolrParams p) throws Exc // flags needs to be called here since only terms response is passed to compare // other way is to pass whole response to compare - Object value = controlRsp._get(List.of(new String[] {"terms"}), null); - Object value1 = rsp._get(List.of(new String[] {"terms"}), null); + Object value = controlRsp._get(List.of("terms"), null); + Object value1 = rsp._get(List.of("terms"), null); assertNull(compare(value1, value, flags(handle, "terms"), handle)); } return queryResponse; 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 f154aca4e4d..6de4ed64b51 100644 --- a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java +++ b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java @@ -1405,7 +1405,7 @@ public void payloadFilteringSpanQuery() throws IOException { hlComp.process(rb); // inspect response NamedList entries = resp.getValues(); - Object value = entries._get(List.of(new String[] {"highlighting", "0", FIELD_NAME}), null); + Object value = entries._get(List.of("highlighting", "0", FIELD_NAME), null); final String[] snippets = (String[]) value; assertEquals("word|7 word|2", snippets[0]); } finally { 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 bf2ce70e626..3045066d0a8 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 @@ -150,13 +150,10 @@ public void testClassicFacets() throws Exception { // AKA SimpleFacets assertEquals(6, getHmObj(response).get("gridLevel")); // same test as above NamedList entries1 = response.getResponse(); Object value1 = - entries1._get( - List.of(new String[] {"facet_counts", "facet_heatmaps", "course", "gridLevel"}), - null); + entries1._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null); assertEquals(2, value1); NamedList entries = response.getResponse(); - Object value = - entries._get(List.of(new String[] {"facet_counts", "facet_heatmaps", "course"}), null); + Object value = entries._get(List.of("facet_counts", "facet_heatmaps", "course"), null); assertTrue(((NamedList) value).indexOf("counts_" + courseFormat, 0) >= 0); } @@ -440,11 +437,11 @@ public void testJsonFacets() throws Exception { + "}")); { NamedList entries1 = response.getResponse(); - Object value1 = entries1._get(List.of(new String[] {"facets", "q1"}), null); + Object value1 = entries1._get(List.of("facets", "q1"), null); final NamedList q1Res = (NamedList) value1; assertEquals("1", q1Res.get("count").toString()); NamedList entries = response.getResponse(); - Object value = entries._get(List.of(new String[] {"facets", "q2"}), null); + Object value = entries._get(List.of("facets", "q2"), null); final NamedList q2Res = (NamedList) value; assertEquals("1", q2Res.get("count").toString()); // essentially, these will differ only in the heatmap counts but otherwise will be the same @@ -506,15 +503,14 @@ public void testJsonFacets() throws Exception { private NamedList getHmObj(QueryResponse response) { // classic faceting NamedList entries1 = response.getResponse(); - Object value1 = - entries1._get(List.of(new String[] {"facet_counts", "facet_heatmaps", FIELD}), null); + Object value1 = entries1._get(List.of("facet_counts", "facet_heatmaps", FIELD), null); final NamedList classicResp = (NamedList) value1; if (classicResp != null) { return classicResp; } // JSON Facet NamedList entries = response.getResponse(); - Object value = entries._get(List.of(new String[] {"facets", "f1"}), null); + Object value = entries._get(List.of("facets", "f1"), null); return (NamedList) value; } 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 31d5ac03c01..3838ed79f89 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 @@ -529,8 +529,7 @@ private NamedList getFacetDebug(final SolrParams params) { assertNotNull(params + " is null topNamedList?", topNamedList); // skip past the (implicit) top Facet query to get it's "sub-facets" (the real facets)... - Object value = - topNamedList._get(List.of(new String[] {"debug", "facet-trace", "sub-facet"}), null); + Object value = topNamedList._get(List.of("debug", "facet-trace", "sub-facet"), null); @SuppressWarnings({"unchecked"}) final List> facetDebug = (List>) value; assertNotNull(topNamedList + " ... null facet debug?", facetDebug); 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 e64f077a8b4..7ac7eeb2f59 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 @@ -678,7 +678,7 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } - Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); + Object value = resp._get(List.of("solr-mbeans", category, key, "stats"), null); @SuppressWarnings({"unchecked"}) Map map = (Map) value; if (map == 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 bb195f25add..c245a92e2f8 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 @@ -613,7 +613,7 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } - Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); + Object value = resp._get(List.of("solr-mbeans", category, key, "stats"), null); @SuppressWarnings({"unchecked"}) Map map = (Map) value; if (map == 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 5ce8b749868..2e1ecb7bf7a 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,36 +142,36 @@ public void testRecursive() { nl.add("key3", nl3); // Simple three-level checks. - Object value11 = nl._get(List.of(new String[] {"key2", "key2b", "key2b2"}), null); + Object value11 = nl._get(List.of("key2", "key2b", "key2b2"), null); String test1 = (String) value11; assertEquals("value2b2", test1); - Object value10 = nl._get(List.of(new String[] {"key3", "key3a", "key3a3"}), null); + Object value10 = nl._get(List.of("key3", "key3a", "key3a3"), null); String test2 = (String) value10; assertEquals("value3a3", test2); // Two-level check. - Object value9 = nl._get(List.of(new String[] {"key3", "key3c"}), null); + Object value9 = nl._get(List.of("key3", "key3c"), null); String test3 = (String) value9; assertEquals("value3c", test3); // Checking that invalid values return null. - Object value8 = nl._get(List.of(new String[] {"key3", "key3c", "invalid"}), null); + Object value8 = nl._get(List.of("key3", "key3c", "invalid"), null); String test4 = (String) value8; assertNull(test4); - Object value7 = nl._get(List.of(new String[] {"key3", "invalid", "invalid"}), null); + Object value7 = nl._get(List.of("key3", "invalid", "invalid"), null); String test5 = (String) value7; assertNull(test5); - Object value6 = nl._get(List.of(new String[] {"invalid", "key3c"}), null); + Object value6 = nl._get(List.of("invalid", "key3c"), null); String test6 = (String) value6; assertNull(test6); // Verify that retrieved NamedList objects have the right type. - Object value5 = nl._get(List.of(new String[] {"key2", "key2b"}), null); + Object value5 = nl._get(List.of("key2", "key2b"), null); Object test7 = value5; assertTrue(test7 instanceof NamedList); // Integer check. - Object value4 = nl._get(List.of(new String[] {"key2", "k2int1"}), null); + Object value4 = nl._get(List.of("key2", "k2int1"), null); int test8 = (Integer) value4; assertEquals(5, test8); // Check that a single argument works the same as get(String). - Object value3 = nl._get(List.of(new String[] {"key1"}), null); + Object value3 = nl._get(List.of("key1"), null); String test9 = (String) value3; assertEquals("value1", test9); // enl == explicit nested list @@ -190,17 +190,17 @@ public void testRecursive() { // Tests that are very similar to the test above, just repeated // on the explicitly nested object type. - Object value2 = enl._get(List.of(new String[] {"key1", "key1a"}), null); + Object value2 = enl._get(List.of("key1", "key1a"), null); String enltest1 = (String) value2; assertEquals("value1a", enltest1); - Object value1 = enl._get(List.of(new String[] {"key1", "key1b"}), null); + Object value1 = enl._get(List.of("key1", "key1b"), null); String enltest2 = (String) value1; 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 value = enl._get(List.of(new String[] {"key2"}), null); + Object value = enl._get(List.of("key2"), null); Object enltest4 = value; 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 dcf1a127bd0..5f7f2551fab 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 @@ -195,7 +195,7 @@ private String _checkBackupSuccess(final String backupName) throws Exception { .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Status of {}: {}", label, data); - Object value = data._get(List.of(new String[] {"details", "backup"}), null); + Object value = data._get(List.of("details", "backup"), null); @SuppressWarnings({"unchecked"}) final NamedList backupData = (NamedList) value; if (null == backupData) { @@ -272,7 +272,7 @@ public boolean checkBackupDeletionSuccess(final String backupName) throws Except .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Deletion Status of {}: {}", backupName, data); - Object value = data._get(List.of(new String[] {"details", "backup"}), null); + Object value = data._get(List.of("details", "backup"), null); @SuppressWarnings({"unchecked"}) final NamedList backupData = (NamedList) value; if (null == backupData From edf1444dcfbea01f97be9266ee235ab572c37601 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Fri, 23 May 2025 09:07:31 +0530 Subject: [PATCH 03/12] Revert "Replace List.of(array) direct arguments" This reverts commit 109d8ff93f79699738890422f1439ee39be3b6b6. --- .../java/org/apache/solr/cli/AssertTool.java | 2 +- .../java/org/apache/solr/cli/ConfigTool.java | 2 +- .../org/apache/solr/cli/HealthcheckTool.java | 9 ++++--- .../java/org/apache/solr/cli/StatusTool.java | 14 +++++------ .../cloud/api/collections/SplitShardCmd.java | 4 ++-- .../solr/handler/component/SearchHandler.java | 9 ++++--- .../solr/packagemanager/PackageManager.java | 2 +- .../solr/cloud/CollectionsAPISolrJTest.java | 14 ++++++----- .../apache/solr/cloud/TestPullReplica.java | 4 +++- .../solr/cloud/TestPullReplicaWithAuth.java | 3 ++- .../cloud/TestSkipOverseerOperations.java | 6 +++-- .../apache/solr/cloud/TestTlogReplica.java | 3 ++- .../TestRequestStatusCollectionAPI.java | 6 ++--- .../FieldAnalysisRequestHandlerTest.java | 3 ++- .../handler/admin/MetricsHandlerTest.java | 18 +++++++------- .../DistributedSpellCheckComponentTest.java | 4 +++- .../DistributedTermsComponentTest.java | 4 ++-- .../solr/highlight/HighlighterTest.java | 2 +- .../facet/SpatialHeatmapFacetsTest.java | 16 ++++++++----- .../facet/TestCloudJSONFacetSKGEquiv.java | 3 ++- .../solrj/impl/CloudHttp2SolrClientTest.java | 2 +- .../solrj/impl/CloudSolrClientTest.java | 2 +- .../solr/common/util/NamedListTest.java | 24 +++++++++---------- .../solr/handler/BackupStatusChecker.java | 4 ++-- 24 files changed, 92 insertions(+), 68 deletions(-) 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 446c70cfbac..e8b0475de32 100644 --- a/solr/core/src/java/org/apache/solr/cli/AssertTool.java +++ b/solr/core/src/java/org/apache/solr/cli/AssertTool.java @@ -281,7 +281,7 @@ public int assertSolrNotRunning(String url, String credentials) throws Exception System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeoutMs, TimeUnit.MILLISECONDS); try (SolrClient solrClient = CLIUtils.getSolrClient(url, credentials)) { NamedList response = solrClient.request(new HealthCheckRequest()); - Object value = response._get(List.of("responseHeader", "status"), null); + Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); Integer statusCode = (Integer) value; CLIUtils.checkCodeForAuthError(statusCode); } catch (IOException | SolrServerException 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 096d0ce7b8f..1b819e56b6c 100644 --- a/solr/core/src/java/org/apache/solr/cli/ConfigTool.java +++ b/solr/core/src/java/org/apache/solr/cli/ConfigTool.java @@ -125,7 +125,7 @@ public void runImpl(CommandLine cli) throws Exception { try (SolrClient solrClient = CLIUtils.getSolrClient(solrUrl, cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION))) { NamedList result = SolrCLI.postJsonToSolr(solrClient, updatePath, jsonBody); - Object value1 = result._get(List.of("responseHeader", "status"), null); + Object value1 = result._get(List.of(new String[] {"responseHeader", "status"}), null); Integer statusCode = (Integer) value1; if (statusCode == 0) { if (value != null) { 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 0a537116dfd..dadd5ba3b89 100644 --- a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java +++ b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java @@ -173,11 +173,14 @@ protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) th solrClient.request( new GenericSolrRequest( SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH)); - Object value2 = systemInfo._get(List.of("jvm", "jmx", "upTimeMS"), null); + Object value2 = + systemInfo._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); uptime = SolrCLI.uptime((Long) value2); - Object value1 = systemInfo._get(List.of("jvm", "memory", "used"), null); + Object value1 = + systemInfo._get(List.of(new String[] {"jvm", "memory", "used"}), null); String usedMemory = (String) value1; - Object value = systemInfo._get(List.of("jvm", "memory", "total"), null); + Object value = + systemInfo._get(List.of(new String[] {"jvm", "memory", "total"}), null); String totalMemory = (String) value; 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 4448ddb8ec1..9cf5fdb72a0 100644 --- a/solr/core/src/java/org/apache/solr/cli/StatusTool.java +++ b/solr/core/src/java/org/apache/solr/cli/StatusTool.java @@ -314,16 +314,16 @@ public static Map reportStatus(NamedList info, SolrClien String solrHome = (String) info.get("solr_home"); status.put("solr_home", solrHome != null ? solrHome : "?"); - Object value4 = info._get(List.of("lucene", "solr-impl-version"), null); + Object value4 = info._get(List.of(new String[] {"lucene", "solr-impl-version"}), null); status.put("version", value4); - Object value3 = info._get(List.of("jvm", "jmx", "startTime"), null); + Object value3 = info._get(List.of(new String[] {"jvm", "jmx", "startTime"}), null); status.put("startTime", value3.toString()); - Object value2 = info._get(List.of("jvm", "jmx", "upTimeMS"), null); + Object value2 = info._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); status.put("uptime", SolrCLI.uptime((Long) value2)); - Object value1 = info._get(List.of("jvm", "memory", "used"), null); + Object value1 = info._get(List.of(new String[] {"jvm", "memory", "used"}), null); String usedMemory = (String) value1; - Object value = info._get(List.of("jvm", "memory", "total"), null); + Object value = info._get(List.of(new String[] {"jvm", "memory", "total"}), null); String totalMemory = (String) value; status.put("memory", usedMemory + " of " + totalMemory); @@ -349,12 +349,12 @@ private static Map getCloudStatus(SolrClient solrClient, String // TODO add booleans to request just what we want; not everything NamedList json = solrClient.request(new CollectionAdminRequest.ClusterStatus()); - Object value1 = json._get(List.of("cluster", "live_nodes"), null); + Object value1 = json._get(List.of(new String[] {"cluster", "live_nodes"}), null); List liveNodes = (List) value1; cloudStatus.put("liveNodes", String.valueOf(liveNodes.size())); // TODO get this as a metric from the metrics API instead, or something else. - Object value = json._get(List.of("cluster", "collections"), null); + Object value = json._get(List.of(new String[] {"cluster", "collections"}), null); var collections = (Map) value; cloudStatus.put("collections", String.valueOf(collections.size())); 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 ea0c4b221b9..651d775fe4d 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 @@ -863,7 +863,7 @@ public static void checkDiskSpace( .process(cloudManager.getSolrClient()); NamedList entries1 = rsp.getResponse(); - Object value1 = entries1._get(List.of("metrics", indexSizeMetricName), null); + Object value1 = entries1._get(List.of(new String[] {"metrics", indexSizeMetricName}), null); Number size = (Number) value1; if (size == null) { log.warn("cannot verify information for parent shard leader"); @@ -872,7 +872,7 @@ public static void checkDiskSpace( double indexSize = size.doubleValue(); NamedList entries = rsp.getResponse(); - Object value = entries._get(List.of("metrics", freeDiskSpaceMetricName), null); + Object value = entries._get(List.of(new String[] {"metrics", freeDiskSpaceMetricName}), null); Number freeSize = (Number) value; if (freeSize == null) { log.warn("missing node disk space information for parent shard leader"); 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 80604807f24..30d8b40a0fa 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 @@ -610,14 +610,17 @@ private void processComponents( return false; } Object value1 = - resp._get(List.of("responseHeader", "partialResults"), null); + resp._get( + List.of(new String[] {"responseHeader", "partialResults"}), null); Object recursive = value1; if (recursive != null) { Object value = resp._get( List.of( - "responseHeader", - RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY), + new String[] { + "responseHeader", + RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY + }), null); Object message = "[Shard:" + response.getShardAddress() + "]" + value; detailMesg.compareAndSet(null, message); // first one, ingore rest 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 7879465100b..b80f1cb2ce4 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 Map getPackagesDeployedAsClusterLevelPlugins NamedList response = solrClient.request( new GenericV2SolrRequest(SolrRequest.METHOD.GET, PackageUtils.CLUSTERPROPS_PATH)); - Object value = response._get(List.of("responseHeader", "status"), null); + Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); Integer statusCode = (Integer) value; if (statusCode == null || statusCode == ErrorCode.NOT_FOUND.code) { // Cluster props doesn't exist, that means there are no cluster level plugins installed. 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 6c4fce82ed2..54a487685a4 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java @@ -621,25 +621,27 @@ public void testColStatus() throws Exception { assertEquals(0, rsp.getStatus()); assertNotNull(rsp.getResponse().get(collectionName)); NamedList entries5 = rsp.getResponse(); - Object value5 = entries5._get(List.of(collectionName, "properties"), null); + Object value5 = entries5._get(List.of(new String[] {collectionName, "properties"}), null); assertNotNull(value5); NamedList entries4 = rsp.getResponse(); - Object value4 = entries4._get(List.of(collectionName, "properties"), null); + Object value4 = entries4._get(List.of(new String[] {collectionName, "properties"}), null); final var collPropMap = (Map) value4; assertEquals("conf2", collPropMap.get("configName")); assertEquals(2L, collPropMap.get("nrtReplicas")); assertEquals("0", collPropMap.get("tlogReplicas")); assertEquals("0", collPropMap.get("pullReplicas")); NamedList entries3 = rsp.getResponse(); - Object value3 = entries3._get(List.of(collectionName, "shards"), null); + Object value3 = entries3._get(List.of(new String[] {collectionName, "shards"}), null); assertEquals(2, ((NamedList) value3).size()); NamedList entries2 = rsp.getResponse(); - Object value2 = entries2._get(List.of(collectionName, "shards", "shard1", "leader"), null); + Object value2 = + entries2._get(List.of(new String[] {collectionName, "shards", "shard1", "leader"}), null); assertNotNull(value2); // Ensure more advanced info is not returned NamedList entries1 = rsp.getResponse(); Object value1 = - entries1._get(List.of(collectionName, "shards", "shard1", "leader", "segInfos"), null); + entries1._get( + List.of(new String[] {collectionName, "shards", "shard1", "leader", "segInfos"}), null); assertNull(value1); // Returns segment metadata iff requested @@ -696,7 +698,7 @@ public void testColStatus() throws Exception { rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); NamedList entries = rsp.getResponse(); - Object value = entries._get(List.of(collectionName, "schemaNonCompliant"), null); + Object value = entries._get(List.of(new String[] {collectionName, "schemaNonCompliant"}), null); @SuppressWarnings({"unchecked"}) List nonCompliant = (List) value; assertEquals(nonCompliant.toString(), 1, nonCompliant.size()); 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 2bad973edb1..2212ba5e264 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java @@ -317,7 +317,9 @@ public void testAddDocs() throws Exception { QueryResponse statsResponse = pullReplicaClient.query(req); // The adds gauge metric should be null for pull replicas since they don't process adds NamedList entries = (statsResponse.getResponse()); - Object value = entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null); + Object value = + entries._get( + List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); assertNull( "Replicas shouldn't process the add document request: " + statsResponse, ((Map) value).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 f818bcc8327..20d849f2e96 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java @@ -155,7 +155,8 @@ public void testPKIAuthWorksForPullReplication() throws Exception { @SuppressWarnings("unchecked") private Object getUpdateHandlerMetric(QueryResponse statsResponse, String metric) { NamedList entries = statsResponse.getResponse(); - Object value = entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null); + Object value = + entries._get(List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); return ((Map) value).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 707146600fb..b3ac36f7517 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java @@ -239,7 +239,8 @@ public boolean matches(SortedSet oldLiveNodes, SortedSet newLive */ private int getNumLeaderOperations(CollectionAdminResponse resp) { NamedList entries = resp.getResponse(); - Object value = entries._get(List.of("overseer_operations", "leader", "requests"), null); + Object value = + entries._get(List.of(new String[] {"overseer_operations", "leader", "requests"}), null); return (int) value; } @@ -249,7 +250,8 @@ private int getNumLeaderOperations(CollectionAdminResponse resp) { */ private int getNumStateOperations(CollectionAdminResponse resp) { NamedList entries = resp.getResponse(); - Object value = entries._get(List.of("overseer_operations", "state", "requests"), null); + Object value = + entries._get(List.of(new String[] {"overseer_operations", "state", "requests"}), null); return (int) value; } 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 767c4a72b42..006034d9349 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java @@ -288,7 +288,8 @@ public void testAddDocs() throws Exception { QueryResponse statsResponse = tlogReplicaClient.query(req); NamedList entries = (statsResponse.getResponse()); Object value = - entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null); + entries._get( + List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); assertEquals( "Append replicas should recive all updates. Replica: " + r 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 e1023c863bc..773d397150b 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 @@ -80,7 +80,7 @@ public void test() { NamedList createResponse = null; try { createResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = createResponse._get(List.of("status", "msg"), null); + Object value = createResponse._get(List.of(new String[] {"status", "msg"}), null); message = (String) value; } catch (SolrServerException | IOException e) { log.error("error sending request", e); @@ -124,7 +124,7 @@ public void test() { NamedList splitResponse = null; try { splitResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = splitResponse._get(List.of("status", "msg"), null); + Object value = splitResponse._get(List.of(new String[] {"status", "msg"}), null); message = (String) value; } catch (SolrServerException | IOException e) { log.error("error sending request", e); @@ -157,7 +157,7 @@ public void test() { try { NamedList response = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = response._get(List.of("status", "msg"), null); + Object value = response._get(List.of(new String[] {"status", "msg"}), null); message = (String) value; } 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 57890aaf9ca..8798d652da7 100644 --- a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java @@ -798,7 +798,8 @@ public TokenStream create(TokenStream input) { @SuppressWarnings({"rawtypes"}) NamedList result = handler.analyzeValues(request, fieldType, "fieldNameUnused"); // just test that we see "900" in the flags attribute here - Object value = result._get(List.of("index", CustomTokenFilter.class.getName()), null); + Object value = + result._get(List.of(new String[] {"index", CustomTokenFilter.class.getName()}), null); @SuppressWarnings({"unchecked", "rawtypes"}) List tokenInfoList = (List) value; // '1' from CustomTokenFilter plus 900 from CustomFlagsAttributeImpl. 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 1e70b20e304..118831f0400 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 @@ -480,7 +480,7 @@ public void testKeyMetrics() throws Exception { key1), resp); NamedList values = resp.getValues(); - Object value4 = values._get(List.of("metrics", key1), null); + Object value4 = values._get(List.of(new String[] {"metrics", key1}), null); Object val = value4; assertNotNull(val); assertTrue(val instanceof MapWriter); @@ -575,9 +575,9 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); NamedList metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value3 = values._get(List.of("errors", "foo"), null); + Object value3 = values._get(List.of(new String[] {"errors", "foo"}), null); assertNotNull(value3); - Object value2 = values._get(List.of("errors", "foo:bar:baz:xyz"), null); + Object value2 = values._get(List.of(new String[] {"errors", "foo:bar:baz:xyz"}), null); assertNotNull(value2); // unknown registry @@ -594,7 +594,7 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value1 = values._get(List.of("errors", "foo:bar:baz"), null); + Object value1 = values._get(List.of(new String[] {"errors", "foo:bar:baz"}), null); assertNotNull(value1); // unknown metric @@ -611,7 +611,7 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value = values._get(List.of("errors", "solr.jetty:unknown:baz"), null); + Object value = values._get(List.of(new String[] {"errors", "solr.jetty:unknown:baz"}), null); assertNotNull(value); handler.close(); @@ -637,7 +637,9 @@ public void testExprMetrics() throws Exception { NamedList entries2 = resp.getValues(); Object value2 = entries2._get( - List.of("metrics", "solr.core.collection1", "QUERY./select.requestTimes"), null); + List.of( + new String[] {"metrics", "solr.core.collection1", "QUERY./select.requestTimes"}), + null); Object val = value2; assertNotNull(val); assertTrue(val instanceof MapWriter); @@ -664,7 +666,7 @@ public void testExprMetrics() throws Exception { resp); // response structure is like in the case of non-key params NamedList entries1 = resp.getValues(); - Object value1 = entries1._get(List.of("metrics", "solr.core.collection1"), null); + Object value1 = entries1._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); val = value1; assertNotNull(val); Object v = ((SimpleOrderedMap) val).get("QUERY./select.requestTimes"); @@ -700,7 +702,7 @@ public void testExprMetrics() throws Exception { key3), resp); NamedList entries = resp.getValues(); - Object value = entries._get(List.of("metrics", "solr.core.collection1"), null); + Object value = entries._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); val = value; assertNotNull(val); // for requestTimes only the full set of values from the first expr should be present 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 dfb314acf63..a9a3fe5e687 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 @@ -64,7 +64,9 @@ private void q(Object... q) throws Exception { public void validateControlData(QueryResponse control) { NamedList nl = control.getResponse(); - Object value = nl._get(List.of("responseHeader", "params", "test.expected.suggestions"), null); + Object value = + nl._get( + List.of(new String[] {"responseHeader", "params", "test.expected.suggestions"}), null); Object explicitNumSuggestExpected = value; @SuppressWarnings("unchecked") 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 c40b00cadbf..6dcb360850e 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 @@ -226,8 +226,8 @@ protected QueryResponse query(boolean setDistribParams, SolrParams p) throws Exc // flags needs to be called here since only terms response is passed to compare // other way is to pass whole response to compare - Object value = controlRsp._get(List.of("terms"), null); - Object value1 = rsp._get(List.of("terms"), null); + Object value = controlRsp._get(List.of(new String[] {"terms"}), null); + Object value1 = rsp._get(List.of(new String[] {"terms"}), null); assertNull(compare(value1, value, flags(handle, "terms"), handle)); } return queryResponse; 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 6de4ed64b51..f154aca4e4d 100644 --- a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java +++ b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java @@ -1405,7 +1405,7 @@ public void payloadFilteringSpanQuery() throws IOException { hlComp.process(rb); // inspect response NamedList entries = resp.getValues(); - Object value = entries._get(List.of("highlighting", "0", FIELD_NAME), null); + Object value = entries._get(List.of(new String[] {"highlighting", "0", FIELD_NAME}), null); final String[] snippets = (String[]) value; assertEquals("word|7 word|2", snippets[0]); } finally { 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 3045066d0a8..bf2ce70e626 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 @@ -150,10 +150,13 @@ public void testClassicFacets() throws Exception { // AKA SimpleFacets assertEquals(6, getHmObj(response).get("gridLevel")); // same test as above NamedList entries1 = response.getResponse(); Object value1 = - entries1._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null); + entries1._get( + List.of(new String[] {"facet_counts", "facet_heatmaps", "course", "gridLevel"}), + null); assertEquals(2, value1); NamedList entries = response.getResponse(); - Object value = entries._get(List.of("facet_counts", "facet_heatmaps", "course"), null); + Object value = + entries._get(List.of(new String[] {"facet_counts", "facet_heatmaps", "course"}), null); assertTrue(((NamedList) value).indexOf("counts_" + courseFormat, 0) >= 0); } @@ -437,11 +440,11 @@ public void testJsonFacets() throws Exception { + "}")); { NamedList entries1 = response.getResponse(); - Object value1 = entries1._get(List.of("facets", "q1"), null); + Object value1 = entries1._get(List.of(new String[] {"facets", "q1"}), null); final NamedList q1Res = (NamedList) value1; assertEquals("1", q1Res.get("count").toString()); NamedList entries = response.getResponse(); - Object value = entries._get(List.of("facets", "q2"), null); + Object value = entries._get(List.of(new String[] {"facets", "q2"}), null); final NamedList q2Res = (NamedList) value; assertEquals("1", q2Res.get("count").toString()); // essentially, these will differ only in the heatmap counts but otherwise will be the same @@ -503,14 +506,15 @@ public void testJsonFacets() throws Exception { private NamedList getHmObj(QueryResponse response) { // classic faceting NamedList entries1 = response.getResponse(); - Object value1 = entries1._get(List.of("facet_counts", "facet_heatmaps", FIELD), null); + Object value1 = + entries1._get(List.of(new String[] {"facet_counts", "facet_heatmaps", FIELD}), null); final NamedList classicResp = (NamedList) value1; if (classicResp != null) { return classicResp; } // JSON Facet NamedList entries = response.getResponse(); - Object value = entries._get(List.of("facets", "f1"), null); + Object value = entries._get(List.of(new String[] {"facets", "f1"}), null); return (NamedList) value; } 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 3838ed79f89..31d5ac03c01 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 @@ -529,7 +529,8 @@ private NamedList getFacetDebug(final SolrParams params) { assertNotNull(params + " is null topNamedList?", topNamedList); // skip past the (implicit) top Facet query to get it's "sub-facets" (the real facets)... - Object value = topNamedList._get(List.of("debug", "facet-trace", "sub-facet"), null); + Object value = + topNamedList._get(List.of(new String[] {"debug", "facet-trace", "sub-facet"}), null); @SuppressWarnings({"unchecked"}) final List> facetDebug = (List>) value; assertNotNull(topNamedList + " ... null facet debug?", facetDebug); 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 7ac7eeb2f59..e64f077a8b4 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 @@ -678,7 +678,7 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } - Object value = resp._get(List.of("solr-mbeans", category, key, "stats"), null); + Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); @SuppressWarnings({"unchecked"}) Map map = (Map) value; if (map == 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 c245a92e2f8..bb195f25add 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 @@ -613,7 +613,7 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } - Object value = resp._get(List.of("solr-mbeans", category, key, "stats"), null); + Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); @SuppressWarnings({"unchecked"}) Map map = (Map) value; if (map == 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 2e1ecb7bf7a..5ce8b749868 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,36 +142,36 @@ public void testRecursive() { nl.add("key3", nl3); // Simple three-level checks. - Object value11 = nl._get(List.of("key2", "key2b", "key2b2"), null); + Object value11 = nl._get(List.of(new String[] {"key2", "key2b", "key2b2"}), null); String test1 = (String) value11; assertEquals("value2b2", test1); - Object value10 = nl._get(List.of("key3", "key3a", "key3a3"), null); + Object value10 = nl._get(List.of(new String[] {"key3", "key3a", "key3a3"}), null); String test2 = (String) value10; assertEquals("value3a3", test2); // Two-level check. - Object value9 = nl._get(List.of("key3", "key3c"), null); + Object value9 = nl._get(List.of(new String[] {"key3", "key3c"}), null); String test3 = (String) value9; assertEquals("value3c", test3); // Checking that invalid values return null. - Object value8 = nl._get(List.of("key3", "key3c", "invalid"), null); + Object value8 = nl._get(List.of(new String[] {"key3", "key3c", "invalid"}), null); String test4 = (String) value8; assertNull(test4); - Object value7 = nl._get(List.of("key3", "invalid", "invalid"), null); + Object value7 = nl._get(List.of(new String[] {"key3", "invalid", "invalid"}), null); String test5 = (String) value7; assertNull(test5); - Object value6 = nl._get(List.of("invalid", "key3c"), null); + Object value6 = nl._get(List.of(new String[] {"invalid", "key3c"}), null); String test6 = (String) value6; assertNull(test6); // Verify that retrieved NamedList objects have the right type. - Object value5 = nl._get(List.of("key2", "key2b"), null); + Object value5 = nl._get(List.of(new String[] {"key2", "key2b"}), null); Object test7 = value5; assertTrue(test7 instanceof NamedList); // Integer check. - Object value4 = nl._get(List.of("key2", "k2int1"), null); + Object value4 = nl._get(List.of(new String[] {"key2", "k2int1"}), null); int test8 = (Integer) value4; assertEquals(5, test8); // Check that a single argument works the same as get(String). - Object value3 = nl._get(List.of("key1"), null); + Object value3 = nl._get(List.of(new String[] {"key1"}), null); String test9 = (String) value3; assertEquals("value1", test9); // enl == explicit nested list @@ -190,17 +190,17 @@ public void testRecursive() { // Tests that are very similar to the test above, just repeated // on the explicitly nested object type. - Object value2 = enl._get(List.of("key1", "key1a"), null); + Object value2 = enl._get(List.of(new String[] {"key1", "key1a"}), null); String enltest1 = (String) value2; assertEquals("value1a", enltest1); - Object value1 = enl._get(List.of("key1", "key1b"), null); + Object value1 = enl._get(List.of(new String[] {"key1", "key1b"}), null); String enltest2 = (String) value1; 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 value = enl._get(List.of("key2"), null); + Object value = enl._get(List.of(new String[] {"key2"}), null); Object enltest4 = value; 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 5f7f2551fab..dcf1a127bd0 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 @@ -195,7 +195,7 @@ private String _checkBackupSuccess(final String backupName) throws Exception { .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Status of {}: {}", label, data); - Object value = data._get(List.of("details", "backup"), null); + Object value = data._get(List.of(new String[] {"details", "backup"}), null); @SuppressWarnings({"unchecked"}) final NamedList backupData = (NamedList) value; if (null == backupData) { @@ -272,7 +272,7 @@ public boolean checkBackupDeletionSuccess(final String backupName) throws Except .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Deletion Status of {}: {}", backupName, data); - Object value = data._get(List.of("details", "backup"), null); + Object value = data._get(List.of(new String[] {"details", "backup"}), null); @SuppressWarnings({"unchecked"}) final NamedList backupData = (NamedList) value; if (null == backupData From 74699710af15600155ea5a40b9a0108df9f682e2 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Fri, 23 May 2025 09:07:43 +0530 Subject: [PATCH 04/12] Revert "SOLR-17625 NamedList.findRecursive-> _get" This reverts commit 81eed8a5e761ae5084af93445989edcb9c11cf24. Changes made with help inline method feature.The methods were over loaded with 1 , 2 ,3 and 4 arguments with String type Updated StatusTool.java SplitShardCmd.java doesnt require update --- .../java/org/apache/solr/cli/AssertTool.java | 3 +- .../java/org/apache/solr/cli/ConfigTool.java | 3 +- .../org/apache/solr/cli/HealthcheckTool.java | 14 +++----- .../java/org/apache/solr/cli/StatusTool.java | 23 +++++------- .../cloud/api/collections/SplitShardCmd.java | 6 ++-- .../solr/handler/component/SearchHandler.java | 24 ++++++------- .../solr/packagemanager/PackageManager.java | 3 +- .../solr/cloud/CollectionsAPISolrJTest.java | 35 ++++++++---------- .../apache/solr/cloud/TestPullReplica.java | 7 ++-- .../solr/cloud/TestPullReplicaWithAuth.java | 6 ++-- .../cloud/TestSkipOverseerOperations.java | 8 ++--- .../apache/solr/cloud/TestTlogReplica.java | 7 ++-- .../TestRequestStatusCollectionAPI.java | 9 ++--- .../FieldAnalysisRequestHandlerTest.java | 5 ++- .../handler/admin/MetricsHandlerTest.java | 28 +++++---------- .../DistributedSpellCheckComponentTest.java | 6 ++-- .../DistributedTermsComponentTest.java | 9 +++-- .../solr/highlight/HighlighterTest.java | 4 +-- .../facet/SpatialHeatmapFacetsTest.java | 29 +++++++-------- .../facet/TestCloudJSONFacetSKGEquiv.java | 6 ++-- .../solrj/impl/CloudHttp2SolrClientTest.java | 4 +-- .../solrj/impl/CloudSolrClientTest.java | 4 +-- .../solr/common/util/NamedListTest.java | 36 +++++++------------ .../solr/handler/BackupStatusChecker.java | 8 ++--- 24 files changed, 114 insertions(+), 173 deletions(-) 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 e8b0475de32..e0349cbf328 100644 --- a/solr/core/src/java/org/apache/solr/cli/AssertTool.java +++ b/solr/core/src/java/org/apache/solr/cli/AssertTool.java @@ -281,8 +281,7 @@ public int assertSolrNotRunning(String url, String credentials) throws Exception System.nanoTime() + TimeUnit.NANOSECONDS.convert(timeoutMs, TimeUnit.MILLISECONDS); try (SolrClient solrClient = CLIUtils.getSolrClient(url, credentials)) { NamedList response = solrClient.request(new HealthCheckRequest()); - Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); - Integer statusCode = (Integer) value; + 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 1b819e56b6c..ce7b644c457 100644 --- a/solr/core/src/java/org/apache/solr/cli/ConfigTool.java +++ b/solr/core/src/java/org/apache/solr/cli/ConfigTool.java @@ -125,8 +125,7 @@ public void runImpl(CommandLine cli) throws Exception { try (SolrClient solrClient = CLIUtils.getSolrClient(solrUrl, cli.getOptionValue(CommonCLIOptions.CREDENTIALS_OPTION))) { NamedList result = SolrCLI.postJsonToSolr(solrClient, updatePath, jsonBody); - Object value1 = result._get(List.of(new String[] {"responseHeader", "status"}), null); - Integer statusCode = (Integer) value1; + 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 dadd5ba3b89..25571b6552a 100644 --- a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java +++ b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java @@ -173,15 +173,11 @@ protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) th solrClient.request( new GenericSolrRequest( SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH)); - Object value2 = - systemInfo._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); - uptime = SolrCLI.uptime((Long) value2); - Object value1 = - systemInfo._get(List.of(new String[] {"jvm", "memory", "used"}), null); - String usedMemory = (String) value1; - Object value = - systemInfo._get(List.of(new String[] {"jvm", "memory", "total"}), null); - String totalMemory = (String) value; + uptime = + SolrCLI.uptime((Long) systemInfo._get(List.of("jvm", "jmx", "upTimeMS"), null)); + String usedMemory = (String) systemInfo._get(List.of("jvm", "memory", "used"), null); + String totalMemory = + (String) systemInfo._get(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 9cf5fdb72a0..426be6729d9 100644 --- a/solr/core/src/java/org/apache/solr/cli/StatusTool.java +++ b/solr/core/src/java/org/apache/solr/cli/StatusTool.java @@ -314,17 +314,12 @@ public static Map reportStatus(NamedList info, SolrClien String solrHome = (String) info.get("solr_home"); status.put("solr_home", solrHome != null ? solrHome : "?"); - Object value4 = info._get(List.of(new String[] {"lucene", "solr-impl-version"}), null); - status.put("version", value4); - Object value3 = info._get(List.of(new String[] {"jvm", "jmx", "startTime"}), null); - status.put("startTime", value3.toString()); - Object value2 = info._get(List.of(new String[] {"jvm", "jmx", "upTimeMS"}), null); - status.put("uptime", SolrCLI.uptime((Long) value2)); - - Object value1 = info._get(List.of(new String[] {"jvm", "memory", "used"}), null); - String usedMemory = (String) value1; - Object value = info._get(List.of(new String[] {"jvm", "memory", "total"}), null); - String totalMemory = (String) value; + status.put("version", info._getStr(List.of("lucene", "solr-impl-version"), null)); + status.put("startTime", info._getStr(List.of("jvm", "jmx", "startTime"), null).toString()); + status.put("uptime", SolrCLI.uptime((Long) info._get(List.of("jvm", "jmx", "upTimeMS"), null))); + + 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 @@ -349,13 +344,11 @@ private static Map getCloudStatus(SolrClient solrClient, String // TODO add booleans to request just what we want; not everything NamedList json = solrClient.request(new CollectionAdminRequest.ClusterStatus()); - Object value1 = json._get(List.of(new String[] {"cluster", "live_nodes"}), null); - List liveNodes = (List) value1; + List liveNodes = (List) 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. - Object value = json._get(List.of(new String[] {"cluster", "collections"}), null); - var collections = (Map) value; + var collections = (Map) 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 651d775fe4d..faf5f154b94 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 @@ -863,8 +863,7 @@ public static void checkDiskSpace( .process(cloudManager.getSolrClient()); NamedList entries1 = rsp.getResponse(); - Object value1 = entries1._get(List.of(new String[] {"metrics", indexSizeMetricName}), null); - Number size = (Number) value1; + Number size = (Number) entries1._get(List.of("metrics", indexSizeMetricName), null); if (size == null) { log.warn("cannot verify information for parent shard leader"); return; @@ -872,8 +871,7 @@ public static void checkDiskSpace( double indexSize = size.doubleValue(); NamedList entries = rsp.getResponse(); - Object value = entries._get(List.of(new String[] {"metrics", freeDiskSpaceMetricName}), null); - Number freeSize = (Number) value; + Number freeSize = (Number) entries._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 30d8b40a0fa..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,20 +609,18 @@ private void processComponents( if (resp == null) { return false; } - Object value1 = - resp._get( - List.of(new String[] {"responseHeader", "partialResults"}), null); - Object recursive = value1; + Object recursive = + resp._get(List.of("responseHeader", "partialResults"), null); if (recursive != null) { - Object value = - resp._get( - List.of( - new String[] { - "responseHeader", - RESPONSE_HEADER_PARTIAL_RESULTS_DETAILS_KEY - }), - null); - Object message = "[Shard:" + response.getShardAddress() + "]" + value; + Object message = + "[Shard:" + + response.getShardAddress() + + "]" + + 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 b80f1cb2ce4..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,8 +284,7 @@ public Map getPackagesDeployedAsClusterLevelPlugins NamedList response = solrClient.request( new GenericV2SolrRequest(SolrRequest.METHOD.GET, PackageUtils.CLUSTERPROPS_PATH)); - Object value = response._get(List.of(new String[] {"responseHeader", "status"}), null); - Integer statusCode = (Integer) value; + 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 54a487685a4..f2fdae944fb 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java @@ -620,29 +620,24 @@ public void testColStatus() throws Exception { CollectionAdminResponse rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); assertNotNull(rsp.getResponse().get(collectionName)); - NamedList entries5 = rsp.getResponse(); - Object value5 = entries5._get(List.of(new String[] {collectionName, "properties"}), null); - assertNotNull(value5); - NamedList entries4 = rsp.getResponse(); - Object value4 = entries4._get(List.of(new String[] {collectionName, "properties"}), null); - final var collPropMap = (Map) value4; + NamedList entries3 = rsp.getResponse(); + assertNotNull(entries3._get(List.of(collectionName, "properties"), null)); + NamedList entries2 = rsp.getResponse(); + final var collPropMap = + (Map) entries2._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")); - NamedList entries3 = rsp.getResponse(); - Object value3 = entries3._get(List.of(new String[] {collectionName, "shards"}), null); - assertEquals(2, ((NamedList) value3).size()); - NamedList entries2 = rsp.getResponse(); - Object value2 = - entries2._get(List.of(new String[] {collectionName, "shards", "shard1", "leader"}), null); - assertNotNull(value2); - // Ensure more advanced info is not returned NamedList entries1 = rsp.getResponse(); - Object value1 = - entries1._get( - List.of(new String[] {collectionName, "shards", "shard1", "leader", "segInfos"}), null); - assertNull(value1); + assertEquals( + 2, ((NamedList) entries1._get(List.of(collectionName, "shards"), null)).size()); + NamedList entries4 = rsp.getResponse(); + assertNotNull(entries4._get(List.of(collectionName, "shards", "shard1", "leader"), null)); + // Ensure more advanced info is not returned + NamedList entries5 = rsp.getResponse(); + assertNull( + entries5._get(List.of(collectionName, "shards", "shard1", "leader", "segInfos"), null)); // Returns segment metadata iff requested req = CollectionAdminRequest.collectionStatus(collectionName); @@ -698,9 +693,9 @@ public void testColStatus() throws Exception { rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); NamedList entries = rsp.getResponse(); - Object value = entries._get(List.of(new String[] {collectionName, "schemaNonCompliant"}), null); @SuppressWarnings({"unchecked"}) - List nonCompliant = (List) value; + List nonCompliant = + (List) entries._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 2212ba5e264..73e7393ae75 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java @@ -317,12 +317,11 @@ public void testAddDocs() throws Exception { QueryResponse statsResponse = pullReplicaClient.query(req); // The adds gauge metric should be null for pull replicas since they don't process adds NamedList entries = (statsResponse.getResponse()); - Object value = - entries._get( - List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); assertNull( "Replicas shouldn't process the add document request: " + statsResponse, - ((Map) value).get("UPDATE.updateHandler.adds")); + ((Map) + entries._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 20d849f2e96..cc52117feed 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplicaWithAuth.java @@ -155,8 +155,8 @@ public void testPKIAuthWorksForPullReplication() throws Exception { @SuppressWarnings("unchecked") private Object getUpdateHandlerMetric(QueryResponse statsResponse, String metric) { NamedList entries = statsResponse.getResponse(); - Object value = - entries._get(List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); - return ((Map) value).get(metric); + return ((Map) + 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 b3ac36f7517..3219d0e05e8 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestSkipOverseerOperations.java @@ -239,9 +239,7 @@ public boolean matches(SortedSet oldLiveNodes, SortedSet newLive */ private int getNumLeaderOperations(CollectionAdminResponse resp) { NamedList entries = resp.getResponse(); - Object value = - entries._get(List.of(new String[] {"overseer_operations", "leader", "requests"}), null); - return (int) value; + return (int) entries._get(List.of("overseer_operations", "leader", "requests"), null); } /** @@ -250,9 +248,7 @@ private int getNumLeaderOperations(CollectionAdminResponse resp) { */ private int getNumStateOperations(CollectionAdminResponse resp) { NamedList entries = resp.getResponse(); - Object value = - entries._get(List.of(new String[] {"overseer_operations", "state", "requests"}), null); - return (int) value; + 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 006034d9349..84d3e2066ab 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java @@ -287,16 +287,15 @@ public void testAddDocs() throws Exception { "stats", "true"); QueryResponse statsResponse = tlogReplicaClient.query(req); NamedList entries = (statsResponse.getResponse()); - Object value = - entries._get( - List.of(new String[] {"plugins", "UPDATE", "updateHandler", "stats"}), null); assertEquals( "Append replicas should recive all updates. Replica: " + r + ", response: " + statsResponse, 1L, - ((Map) value).get("UPDATE.updateHandler.cumulativeAdds.count")); + ((Map) + entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null)) + .get("UPDATE.updateHandler.cumulativeAdds.count")); break; } catch (AssertionError e) { if (t.hasTimedOut()) { 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 773d397150b..bfc6cd68506 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 @@ -80,8 +80,7 @@ public void test() { NamedList createResponse = null; try { createResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = createResponse._get(List.of(new String[] {"status", "msg"}), null); - message = (String) value; + message = (String) createResponse._get(List.of("status", "msg"), null); } catch (SolrServerException | IOException e) { log.error("error sending request", e); } @@ -124,8 +123,7 @@ public void test() { NamedList splitResponse = null; try { splitResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = splitResponse._get(List.of(new String[] {"status", "msg"}), null); - message = (String) value; + message = (String) splitResponse._get(List.of("status", "msg"), null); } catch (SolrServerException | IOException e) { log.error("error sending request", e); } @@ -157,8 +155,7 @@ public void test() { try { NamedList response = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - Object value = response._get(List.of(new String[] {"status", "msg"}), null); - message = (String) value; + message = (String) response._get(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 8798d652da7..36b293ed8ab 100644 --- a/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java +++ b/solr/core/src/test/org/apache/solr/handler/FieldAnalysisRequestHandlerTest.java @@ -798,10 +798,9 @@ public TokenStream create(TokenStream input) { @SuppressWarnings({"rawtypes"}) NamedList result = handler.analyzeValues(request, fieldType, "fieldNameUnused"); // just test that we see "900" in the flags attribute here - Object value = - result._get(List.of(new String[] {"index", CustomTokenFilter.class.getName()}), null); @SuppressWarnings({"unchecked", "rawtypes"}) - List tokenInfoList = (List) value; + List tokenInfoList = + (List) 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 118831f0400..2306cb9ceca 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 @@ -480,8 +480,7 @@ public void testKeyMetrics() throws Exception { key1), resp); NamedList values = resp.getValues(); - Object value4 = values._get(List.of(new String[] {"metrics", key1}), null); - Object val = value4; + Object val = values._get(List.of("metrics", key1), null); assertNotNull(val); assertTrue(val instanceof MapWriter); assertTrue(((MapWriter) val)._size() >= 2); @@ -575,10 +574,8 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); NamedList metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value3 = values._get(List.of(new String[] {"errors", "foo"}), null); - assertNotNull(value3); - Object value2 = values._get(List.of(new String[] {"errors", "foo:bar:baz:xyz"}), null); - assertNotNull(value2); + assertNotNull(values._get(List.of("errors", "foo"), null)); + assertNotNull(values._get(List.of("errors", "foo:bar:baz:xyz"), null)); // unknown registry resp = new SolrQueryResponse(); @@ -594,8 +591,7 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value1 = values._get(List.of(new String[] {"errors", "foo:bar:baz"}), null); - assertNotNull(value1); + assertNotNull(values._get(List.of("errors", "foo:bar:baz"), null)); // unknown metric resp = new SolrQueryResponse(); @@ -611,8 +607,7 @@ public void testKeyMetrics() throws Exception { values = resp.getValues(); metrics = (NamedList) values.get("metrics"); assertEquals(0, metrics.size()); - Object value = values._get(List.of(new String[] {"errors", "solr.jetty:unknown:baz"}), null); - assertNotNull(value); + assertNotNull(values._get(List.of("errors", "solr.jetty:unknown:baz"), null)); handler.close(); } @@ -635,12 +630,9 @@ public void testExprMetrics() throws Exception { resp); // response structure is like in the case of non-key params NamedList entries2 = resp.getValues(); - Object value2 = + Object val = entries2._get( - List.of( - new String[] {"metrics", "solr.core.collection1", "QUERY./select.requestTimes"}), - null); - Object val = value2; + List.of("metrics", "solr.core.collection1", "QUERY./select.requestTimes"), null); assertNotNull(val); assertTrue(val instanceof MapWriter); Map map = new HashMap<>(); @@ -666,8 +658,7 @@ public void testExprMetrics() throws Exception { resp); // response structure is like in the case of non-key params NamedList entries1 = resp.getValues(); - Object value1 = entries1._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); - val = value1; + val = entries1._get(List.of("metrics", "solr.core.collection1"), null); assertNotNull(val); Object v = ((SimpleOrderedMap) val).get("QUERY./select.requestTimes"); assertNotNull(v); @@ -702,8 +693,7 @@ public void testExprMetrics() throws Exception { key3), resp); NamedList entries = resp.getValues(); - Object value = entries._get(List.of(new String[] {"metrics", "solr.core.collection1"}), null); - val = value; + val = entries._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 a9a3fe5e687..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 @@ -64,10 +64,8 @@ private void q(Object... q) throws Exception { public void validateControlData(QueryResponse control) { NamedList nl = control.getResponse(); - Object value = - nl._get( - List.of(new String[] {"responseHeader", "params", "test.expected.suggestions"}), null); - Object explicitNumSuggestExpected = value; + Object explicitNumSuggestExpected = + nl._get(List.of("responseHeader", "params", "test.expected.suggestions"), null); @SuppressWarnings("unchecked") NamedList sc = (NamedList) 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 6dcb360850e..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 @@ -226,9 +226,12 @@ protected QueryResponse query(boolean setDistribParams, SolrParams p) throws Exc // flags needs to be called here since only terms response is passed to compare // other way is to pass whole response to compare - Object value = controlRsp._get(List.of(new String[] {"terms"}), null); - Object value1 = rsp._get(List.of(new String[] {"terms"}), null); - assertNull(compare(value1, value, flags(handle, "terms"), handle)); + assertNull( + compare( + rsp._get(List.of("terms"), null), + controlRsp._get(List.of("terms"), null), + flags(handle, "terms"), + handle)); } return queryResponse; } 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 f154aca4e4d..ab8c4cd2512 100644 --- a/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java +++ b/solr/core/src/test/org/apache/solr/highlight/HighlighterTest.java @@ -1405,8 +1405,8 @@ public void payloadFilteringSpanQuery() throws IOException { hlComp.process(rb); // inspect response NamedList entries = resp.getValues(); - Object value = entries._get(List.of(new String[] {"highlighting", "0", FIELD_NAME}), null); - final String[] snippets = (String[]) value; + final String[] snippets = + (String[]) entries._get(List.of("highlighting", "0", FIELD_NAME), null); assertEquals("word|7 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 bf2ce70e626..aeaaae0134e 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 @@ -149,15 +149,14 @@ public void testClassicFacets() throws Exception { // AKA SimpleFacets final QueryResponse response = query(params); assertEquals(6, getHmObj(response).get("gridLevel")); // same test as above NamedList entries1 = response.getResponse(); - Object value1 = - entries1._get( - List.of(new String[] {"facet_counts", "facet_heatmaps", "course", "gridLevel"}), - null); - assertEquals(2, value1); + assertEquals( + 2, entries1._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null)); NamedList entries = response.getResponse(); - Object value = - entries._get(List.of(new String[] {"facet_counts", "facet_heatmaps", "course"}), null); - assertTrue(((NamedList) value).indexOf("counts_" + courseFormat, 0) >= 0); + assertTrue( + ((NamedList) + entries._get(List.of("facet_counts", "facet_heatmaps", "course"), null)) + .indexOf("counts_" + courseFormat, 0) + >= 0); } // ------ Index data @@ -440,12 +439,10 @@ public void testJsonFacets() throws Exception { + "}")); { NamedList entries1 = response.getResponse(); - Object value1 = entries1._get(List.of(new String[] {"facets", "q1"}), null); - final NamedList q1Res = (NamedList) value1; + final NamedList q1Res = (NamedList) entries1._get(List.of("facets", "q1"), null); assertEquals("1", q1Res.get("count").toString()); NamedList entries = response.getResponse(); - Object value = entries._get(List.of(new String[] {"facets", "q2"}), null); - final NamedList q2Res = (NamedList) value; + 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)); @@ -506,16 +503,14 @@ public void testJsonFacets() throws Exception { private NamedList getHmObj(QueryResponse response) { // classic faceting NamedList entries1 = response.getResponse(); - Object value1 = - entries1._get(List.of(new String[] {"facet_counts", "facet_heatmaps", FIELD}), null); - final NamedList classicResp = (NamedList) value1; + final NamedList classicResp = + (NamedList) entries1._get(List.of("facet_counts", "facet_heatmaps", FIELD), null); if (classicResp != null) { return classicResp; } // JSON Facet NamedList entries = response.getResponse(); - Object value = entries._get(List.of(new String[] {"facets", "f1"}), null); - return (NamedList) value; + return (NamedList) entries._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 31d5ac03c01..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 @@ -529,10 +529,10 @@ private NamedList getFacetDebug(final SolrParams params) { assertNotNull(params + " is null topNamedList?", topNamedList); // skip past the (implicit) top Facet query to get it's "sub-facets" (the real facets)... - Object value = - topNamedList._get(List.of(new String[] {"debug", "facet-trace", "sub-facet"}), null); @SuppressWarnings({"unchecked"}) - final List> facetDebug = (List>) value; + final List> facetDebug = + (List>) + 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 e64f077a8b4..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 @@ -678,9 +678,9 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } - Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); @SuppressWarnings({"unchecked"}) - Map map = (Map) value; + Map map = + (Map) 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 bb195f25add..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 @@ -613,9 +613,9 @@ private Long getNumRequests( } else { name = category + "." + (scope != null ? scope : key) + ".requests"; } - Object value = resp._get(List.of(new String[] {"solr-mbeans", category, key, "stats"}), null); @SuppressWarnings({"unchecked"}) - Map map = (Map) value; + Map map = + (Map) 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 5ce8b749868..e3812f74343 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,37 +142,28 @@ public void testRecursive() { nl.add("key3", nl3); // Simple three-level checks. - Object value11 = nl._get(List.of(new String[] {"key2", "key2b", "key2b2"}), null); - String test1 = (String) value11; + String test1 = (String) nl._get(List.of("key2", "key2b", "key2b2"), null); assertEquals("value2b2", test1); - Object value10 = nl._get(List.of(new String[] {"key3", "key3a", "key3a3"}), null); - String test2 = (String) value10; + String test2 = (String) nl._get(List.of("key3", "key3a", "key3a3"), null); assertEquals("value3a3", test2); // Two-level check. - Object value9 = nl._get(List.of(new String[] {"key3", "key3c"}), null); - String test3 = (String) value9; + String test3 = (String) nl._get(List.of("key3", "key3c"), null); assertEquals("value3c", test3); // Checking that invalid values return null. - Object value8 = nl._get(List.of(new String[] {"key3", "key3c", "invalid"}), null); - String test4 = (String) value8; + String test4 = (String) nl._get(List.of("key3", "key3c", "invalid"), null); assertNull(test4); - Object value7 = nl._get(List.of(new String[] {"key3", "invalid", "invalid"}), null); - String test5 = (String) value7; + String test5 = (String) nl._get(List.of("key3", "invalid", "invalid"), null); assertNull(test5); - Object value6 = nl._get(List.of(new String[] {"invalid", "key3c"}), null); - String test6 = (String) value6; + String test6 = (String) nl._get(List.of("invalid", "key3c"), null); assertNull(test6); // Verify that retrieved NamedList objects have the right type. - Object value5 = nl._get(List.of(new String[] {"key2", "key2b"}), null); - Object test7 = value5; + Object test7 = nl._get(List.of("key2", "key2b"), null); assertTrue(test7 instanceof NamedList); // Integer check. - Object value4 = nl._get(List.of(new String[] {"key2", "k2int1"}), null); - int test8 = (Integer) value4; + int test8 = (Integer) nl._get(List.of("key2", "k2int1"), null); assertEquals(5, test8); // Check that a single argument works the same as get(String). - Object value3 = nl._get(List.of(new String[] {"key1"}), null); - String test9 = (String) value3; + String test9 = (String) nl._get(List.of("key1"), null); assertEquals("value1", test9); // enl == explicit nested list // @@ -190,18 +181,15 @@ public void testRecursive() { // Tests that are very similar to the test above, just repeated // on the explicitly nested object type. - Object value2 = enl._get(List.of(new String[] {"key1", "key1a"}), null); - String enltest1 = (String) value2; + String enltest1 = (String) enl._get(List.of("key1", "key1a"), null); assertEquals("value1a", enltest1); - Object value1 = enl._get(List.of(new String[] {"key1", "key1b"}), null); - String enltest2 = (String) value1; + String enltest2 = (String) enl._get(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 value = enl._get(List.of(new String[] {"key2"}), null); - Object enltest4 = value; + 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 dcf1a127bd0..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 @@ -195,9 +195,9 @@ private String _checkBackupSuccess(final String backupName) throws Exception { .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Status of {}: {}", label, data); - Object value = data._get(List.of(new String[] {"details", "backup"}), null); @SuppressWarnings({"unchecked"}) - final NamedList backupData = (NamedList) value; + final NamedList backupData = + (NamedList) data._get(List.of("details", "backup"), null); if (null == backupData) { // no backup has finished yet return null; @@ -272,9 +272,9 @@ public boolean checkBackupDeletionSuccess(final String backupName) throws Except .process(client); final NamedList data = rsp.getResponse(); log.info("Checking Deletion Status of {}: {}", backupName, data); - Object value = data._get(List.of(new String[] {"details", "backup"}), null); @SuppressWarnings({"unchecked"}) - final NamedList backupData = (NamedList) value; + final NamedList backupData = + (NamedList) data._get(List.of("details", "backup"), null); if (null == backupData || null == backupData.get("status") || !backupName.equals(backupData.get("snapshotName"))) { From 2de2b7f2e5fb9c0aa2545d26f32220406a8f3dce Mon Sep 17 00:00:00 2001 From: Gaurav Date: Tue, 27 May 2025 19:32:44 +0530 Subject: [PATCH 05/12] Revert "SOLR-17625 NamedList.findRecursive-> _get" This reverts commit 81eed8a5e761ae5084af93445989edcb9c11cf24. Changes made with help inline method feature.The methods were over loaded with 1 , 2 ,3 and 4 arguments with String type Updated StatusTool.java SplitShardCmd.java doesnt require update --- solr/core/src/java/org/apache/solr/cli/StatusTool.java | 4 ++-- .../apache/solr/cloud/api/collections/SplitShardCmd.java | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) 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 426be6729d9..2f7422c054f 100644 --- a/solr/core/src/java/org/apache/solr/cli/StatusTool.java +++ b/solr/core/src/java/org/apache/solr/cli/StatusTool.java @@ -315,11 +315,11 @@ public static Map reportStatus(NamedList info, SolrClien String solrHome = (String) info.get("solr_home"); status.put("solr_home", solrHome != null ? solrHome : "?"); status.put("version", info._getStr(List.of("lucene", "solr-impl-version"), null)); - status.put("startTime", info._getStr(List.of("jvm", "jmx", "startTime"), null).toString()); + 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 = info._getStr(List.of("jvm", "memory", "used"), null); - String totalMemory = info._getStr(List.of("jvm", "memory", "total"), 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 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 faf5f154b94..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,16 +862,15 @@ public static void checkDiskSpace( SolrRequest.METHOD.GET, "/admin/metrics", SolrRequest.SolrRequestType.ADMIN, params) .process(cloudManager.getSolrClient()); - NamedList entries1 = rsp.getResponse(); - Number size = (Number) entries1._get(List.of("metrics", indexSizeMetricName), null); + 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(); - NamedList entries = rsp.getResponse(); - Number freeSize = (Number) entries._get(List.of("metrics", freeDiskSpaceMetricName), null); + 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; From 6ca7b330526218a22253018d2510cd972365ae90 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Tue, 27 May 2025 22:40:02 +0530 Subject: [PATCH 06/12] Revert "SOLR-17625 NamedList.findRecursive-> _get" This reverts commit 81eed8a5e761ae5084af93445989edcb9c11cf24. Changes made with help inline method feature.The methods were over loaded with 1 , 2 ,3 and 4 arguments with String type update --- .../solr/cloud/CollectionsAPISolrJTest.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) 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 f2fdae944fb..2554d6676f9 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java @@ -620,24 +620,23 @@ public void testColStatus() throws Exception { CollectionAdminResponse rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); assertNotNull(rsp.getResponse().get(collectionName)); - NamedList entries3 = rsp.getResponse(); - assertNotNull(entries3._get(List.of(collectionName, "properties"), null)); - NamedList entries2 = rsp.getResponse(); + assertNotNull(rsp.getResponse()._get(List.of(collectionName, "properties"), null)); final var collPropMap = - (Map) entries2._get(List.of(collectionName, "properties"), null); + (Map) 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")); - NamedList entries1 = rsp.getResponse(); assertEquals( - 2, ((NamedList) entries1._get(List.of(collectionName, "shards"), null)).size()); - NamedList entries4 = rsp.getResponse(); - assertNotNull(entries4._get(List.of(collectionName, "shards", "shard1", "leader"), null)); + 2, + ((NamedList) 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 - NamedList entries5 = rsp.getResponse(); assertNull( - entries5._get(List.of(collectionName, "shards", "shard1", "leader", "segInfos"), null)); + rsp.getResponse() + ._get(List.of(collectionName, "shards", "shard1", "leader", "segInfos"), null)); // Returns segment metadata iff requested req = CollectionAdminRequest.collectionStatus(collectionName); @@ -692,10 +691,9 @@ public void testColStatus() throws Exception { req.setWithSizeInfo(true); rsp = req.process(cluster.getSolrClient()); assertEquals(0, rsp.getStatus()); - NamedList entries = rsp.getResponse(); @SuppressWarnings({"unchecked"}) List nonCompliant = - (List) entries._get(List.of(collectionName, "schemaNonCompliant"), null); + (List) rsp.getResponse()._get(List.of(collectionName, "schemaNonCompliant"), null); assertEquals(nonCompliant.toString(), 1, nonCompliant.size()); assertTrue(nonCompliant.toString(), nonCompliant.contains("(NONE)")); @SuppressWarnings({"unchecked"}) From 811f31a685dceddc6fdc2cf4ba937eac6a082913 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Wed, 28 May 2025 13:21:57 +0530 Subject: [PATCH 07/12] Revert "SOLR-17625 NamedList.findRecursive-> _get" This reverts commit 81eed8a5e761ae5084af93445989edcb9c11cf24. Changes made with help inline method feature.The methods were over loaded with 1 , 2 ,3 and 4 arguments with String type update --- .../org/apache/solr/cli/HealthcheckTool.java | 5 ++--- .../solr/cloud/CollectionsAPISolrJTest.java | 4 ++-- .../org/apache/solr/cloud/TestPullReplica.java | 5 ++--- .../TestRequestStatusCollectionAPI.java | 6 +++--- .../apache/solr/common/util/NamedListTest.java | 18 +++++++++--------- 5 files changed, 18 insertions(+), 20 deletions(-) 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 25571b6552a..bf795a51596 100644 --- a/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java +++ b/solr/core/src/java/org/apache/solr/cli/HealthcheckTool.java @@ -175,9 +175,8 @@ protected void runCloudTool(CloudSolrClient cloudSolrClient, CommandLine cli) th SolrRequest.METHOD.GET, CommonParams.SYSTEM_INFO_PATH)); uptime = SolrCLI.uptime((Long) systemInfo._get(List.of("jvm", "jmx", "upTimeMS"), null)); - String usedMemory = (String) systemInfo._get(List.of("jvm", "memory", "used"), null); - String totalMemory = - (String) systemInfo._get(List.of("jvm", "memory", "total"), 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/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTest.java index 2554d6676f9..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 void testCloudInfoInCoreStatus() throws IOException, SolrServerException 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))) { 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 73e7393ae75..38ad8bf4f3d 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestPullReplica.java @@ -54,7 +54,6 @@ import org.apache.solr.common.cloud.Replica; import org.apache.solr.common.cloud.Slice; import org.apache.solr.common.cloud.ZkStateReader; -import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.TimeSource; import org.apache.solr.core.CoreDescriptor; import org.apache.solr.core.SolrCore; @@ -316,11 +315,11 @@ public void testAddDocs() throws Exception { SolrQuery req = new SolrQuery("qt", "/admin/plugins", "stats", "true"); QueryResponse statsResponse = pullReplicaClient.query(req); // The adds gauge metric should be null for pull replicas since they don't process adds - NamedList entries = (statsResponse.getResponse()); assertNull( "Replicas shouldn't process the add document request: " + statsResponse, ((Map) - entries._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null)) + (statsResponse.getResponse()) + ._get(List.of("plugins", "UPDATE", "updateHandler", "stats"), null)) .get("UPDATE.updateHandler.adds")); } } 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 bfc6cd68506..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 @@ -80,7 +80,7 @@ public void test() { NamedList createResponse = null; try { createResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - message = (String) createResponse._get(List.of("status", "msg"), null); + message = createResponse._getStr(List.of("status", "msg"), null); } catch (SolrServerException | IOException e) { log.error("error sending request", e); } @@ -123,7 +123,7 @@ public void test() { NamedList splitResponse = null; try { splitResponse = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - message = (String) splitResponse._get(List.of("status", "msg"), null); + message = splitResponse._getStr(List.of("status", "msg"), null); } catch (SolrServerException | IOException e) { log.error("error sending request", e); } @@ -155,7 +155,7 @@ public void test() { try { NamedList response = sendStatusRequestWithRetry(params, MAX_WAIT_TIMEOUT_SECONDS); - message = (String) response._get(List.of("status", "msg"), null); + message = response._getStr(List.of("status", "msg"), null); } catch (SolrServerException | IOException e) { log.error("error sending request", e); } 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 e3812f74343..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,19 +142,19 @@ public void testRecursive() { nl.add("key3", nl3); // Simple three-level checks. - String test1 = (String) nl._get(List.of("key2", "key2b", "key2b2"), null); + String test1 = nl._getStr(List.of("key2", "key2b", "key2b2"), null); assertEquals("value2b2", test1); - String test2 = (String) nl._get(List.of("key3", "key3a", "key3a3"), null); + String test2 = nl._getStr(List.of("key3", "key3a", "key3a3"), null); assertEquals("value3a3", test2); // Two-level check. - String test3 = (String) nl._get(List.of("key3", "key3c"), null); + String test3 = nl._getStr(List.of("key3", "key3c"), null); assertEquals("value3c", test3); // Checking that invalid values return null. - String test4 = (String) nl._get(List.of("key3", "key3c", "invalid"), null); + String test4 = nl._getStr(List.of("key3", "key3c", "invalid"), null); assertNull(test4); - String test5 = (String) nl._get(List.of("key3", "invalid", "invalid"), null); + String test5 = nl._getStr(List.of("key3", "invalid", "invalid"), null); assertNull(test5); - String test6 = (String) nl._get(List.of("invalid", "key3c"), null); + String test6 = nl._getStr(List.of("invalid", "key3c"), null); assertNull(test6); // Verify that retrieved NamedList objects have the right type. Object test7 = nl._get(List.of("key2", "key2b"), null); @@ -163,7 +163,7 @@ public void testRecursive() { 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._get(List.of("key1"), null); + String test9 = nl._getStr(List.of("key1"), null); assertEquals("value1", test9); // enl == explicit nested list // @@ -181,9 +181,9 @@ public void testRecursive() { // Tests that are very similar to the test above, just repeated // on the explicitly nested object type. - String enltest1 = (String) enl._get(List.of("key1", "key1a"), null); + String enltest1 = enl._getStr(List.of("key1", "key1a"), null); assertEquals("value1a", enltest1); - String enltest2 = (String) enl._get(List.of("key1", "key1b"), null); + 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. From 5d2fc5d90e82dfe15e9dfbecb0574a3f741dfd7e Mon Sep 17 00:00:00 2001 From: Gaurav Date: Thu, 29 May 2025 21:06:50 +0530 Subject: [PATCH 08/12] Revert "SOLR-17625 NamedList.findRecursive-> _get" This reverts commit 81eed8a5e761ae5084af93445989edcb9c11cf24. Changes made with help inline method feature.The methods were over loaded with 1 , 2 ,3 and 4 arguments with String type update --- .../handler/admin/MetricsHandlerTest.java | 11 ++++------ .../facet/SpatialHeatmapFacetsTest.java | 21 +++++++------------ 2 files changed, 12 insertions(+), 20 deletions(-) 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 2306cb9ceca..d7e9705b093 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 @@ -629,9 +629,8 @@ public void testExprMetrics() throws Exception { key1), resp); // response structure is like in the case of non-key params - NamedList entries2 = resp.getValues(); - Object val = - entries2._get( + Object val = + resp.getValues()._get( List.of("metrics", "solr.core.collection1", "QUERY./select.requestTimes"), null); assertNotNull(val); assertTrue(val instanceof MapWriter); @@ -657,8 +656,7 @@ public void testExprMetrics() throws Exception { key2), resp); // response structure is like in the case of non-key params - NamedList entries1 = resp.getValues(); - val = entries1._get(List.of("metrics", "solr.core.collection1"), null); + val = resp.getValues()._get(List.of("metrics", "solr.core.collection1"), null); assertNotNull(val); Object v = ((SimpleOrderedMap) val).get("QUERY./select.requestTimes"); assertNotNull(v); @@ -692,8 +690,7 @@ public void testExprMetrics() throws Exception { MetricsHandler.EXPR_PARAM, key3), resp); - NamedList entries = resp.getValues(); - val = entries._get(List.of("metrics", "solr.core.collection1"), null); + 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/search/facet/SpatialHeatmapFacetsTest.java b/solr/core/src/test/org/apache/solr/search/facet/SpatialHeatmapFacetsTest.java index aeaaae0134e..498caa0d438 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 @@ -148,13 +148,11 @@ public void testClassicFacets() throws Exception { // AKA SimpleFacets + FIELD); final QueryResponse response = query(params); assertEquals(6, getHmObj(response).get("gridLevel")); // same test as above - NamedList entries1 = response.getResponse(); - assertEquals( - 2, entries1._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null)); - NamedList entries = response.getResponse(); - assertTrue( + assertEquals( + 2, response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null)); + assertTrue( ((NamedList) - entries._get(List.of("facet_counts", "facet_heatmaps", "course"), null)) + response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", "course"), null)) .indexOf("counts_" + courseFormat, 0) >= 0); } @@ -438,8 +436,7 @@ public void testJsonFacets() throws Exception { + " } " + "}")); { - NamedList entries1 = response.getResponse(); - final NamedList q1Res = (NamedList) entries1._get(List.of("facets", "q1"), null); + final NamedList q1Res = (NamedList) response.getResponse()._get(List.of("facets", "q1"), null); assertEquals("1", q1Res.get("count").toString()); NamedList entries = response.getResponse(); final NamedList q2Res = (NamedList) entries._get(List.of("facets", "q2"), null); @@ -502,15 +499,13 @@ public void testJsonFacets() throws Exception { private NamedList getHmObj(QueryResponse response) { // classic faceting - NamedList entries1 = response.getResponse(); - final NamedList classicResp = - (NamedList) entries1._get(List.of("facet_counts", "facet_heatmaps", FIELD), null); + final NamedList classicResp = + (NamedList) response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", FIELD), null); if (classicResp != null) { return classicResp; } // JSON Facet - NamedList entries = response.getResponse(); - return (NamedList) entries._get(List.of("facets", "f1"), null); + return (NamedList) response.getResponse()._get(List.of("facets", "f1"), null); } @Test From 8d7bd70b0b157faaf78696161e1696e3192f4a68 Mon Sep 17 00:00:00 2001 From: Gaurav Date: Sat, 31 May 2025 23:29:46 +0530 Subject: [PATCH 09/12] Revert "SOLR-17625 NamedList.findRecursive-> _get" This reverts commit 81eed8a5e761ae5084af93445989edcb9c11cf24. Changes made with help inline method feature.The methods were over loaded with 1 , 2 ,3 and 4 arguments with String type update --- .../handler/admin/MetricsHandlerTest.java | 10 ++++---- .../facet/SpatialHeatmapFacetsTest.java | 23 ++++++++++++------- 2 files changed, 20 insertions(+), 13 deletions(-) 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 d7e9705b093..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 @@ -629,9 +629,9 @@ public void testExprMetrics() throws Exception { key1), resp); // response structure is like in the case of non-key params - Object val = - resp.getValues()._get( - List.of("metrics", "solr.core.collection1", "QUERY./select.requestTimes"), null); + Object val = + resp.getValues() + ._get(List.of("metrics", "solr.core.collection1", "QUERY./select.requestTimes"), null); assertNotNull(val); assertTrue(val instanceof MapWriter); Map map = new HashMap<>(); @@ -656,7 +656,7 @@ public void testExprMetrics() throws Exception { key2), resp); // response structure is like in the case of non-key params - val = resp.getValues()._get(List.of("metrics", "solr.core.collection1"), null); + val = resp.getValues()._get(List.of("metrics", "solr.core.collection1"), null); assertNotNull(val); Object v = ((SimpleOrderedMap) val).get("QUERY./select.requestTimes"); assertNotNull(v); @@ -690,7 +690,7 @@ public void testExprMetrics() throws Exception { MetricsHandler.EXPR_PARAM, key3), resp); - val = resp.getValues()._get(List.of("metrics", "solr.core.collection1"), null); + 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/search/facet/SpatialHeatmapFacetsTest.java b/solr/core/src/test/org/apache/solr/search/facet/SpatialHeatmapFacetsTest.java index 498caa0d438..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 @@ -148,11 +148,16 @@ public void testClassicFacets() throws Exception { // AKA SimpleFacets + FIELD); final QueryResponse response = query(params); assertEquals(6, getHmObj(response).get("gridLevel")); // same test as above - assertEquals( - 2, response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null)); - assertTrue( + assertEquals( + 2, + response + .getResponse() + ._get(List.of("facet_counts", "facet_heatmaps", "course", "gridLevel"), null)); + assertTrue( ((NamedList) - response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", "course"), null)) + response + .getResponse() + ._get(List.of("facet_counts", "facet_heatmaps", "course"), null)) .indexOf("counts_" + courseFormat, 0) >= 0); } @@ -436,7 +441,8 @@ public void testJsonFacets() throws Exception { + " } " + "}")); { - final NamedList q1Res = (NamedList) response.getResponse()._get(List.of("facets", "q1"), null); + final NamedList q1Res = + (NamedList) response.getResponse()._get(List.of("facets", "q1"), null); assertEquals("1", q1Res.get("count").toString()); NamedList entries = response.getResponse(); final NamedList q2Res = (NamedList) entries._get(List.of("facets", "q2"), null); @@ -499,13 +505,14 @@ public void testJsonFacets() throws Exception { private NamedList getHmObj(QueryResponse response) { // classic faceting - final NamedList classicResp = - (NamedList) response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", FIELD), null); + final NamedList classicResp = + (NamedList) + response.getResponse()._get(List.of("facet_counts", "facet_heatmaps", FIELD), null); if (classicResp != null) { return classicResp; } // JSON Facet - return (NamedList) response.getResponse()._get(List.of("facets", "f1"), null); + return (NamedList) response.getResponse()._get(List.of("facets", "f1"), null); } @Test From 3139ee0014cad83da566d33ac0831f8b5678ecae Mon Sep 17 00:00:00 2001 From: David Smiley Date: Mon, 2 Jun 2025 00:03:00 -0400 Subject: [PATCH 10/12] CHANGES.txt --- solr/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index db2e7aed119..5f91553aefe 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -186,6 +186,9 @@ Other Changes * SOLR-17703: SolrJ - Rename BinaryResponseParser and BinaryRequestWriter including StreamingBinaryResponseParser to "JavaBin.." equivalent. (Abhishek Umarjikar) +* 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.9.0 ================== New Features --------------------- From 1d7d2a0d103dd05777d9fb9f78ee97542aa6bdcd Mon Sep 17 00:00:00 2001 From: David Smiley Date: Mon, 2 Jun 2025 00:03:49 -0400 Subject: [PATCH 11/12] revert --- solr/CHANGES.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5f91553aefe..db2e7aed119 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -186,9 +186,6 @@ Other Changes * SOLR-17703: SolrJ - Rename BinaryResponseParser and BinaryRequestWriter including StreamingBinaryResponseParser to "JavaBin.." equivalent. (Abhishek Umarjikar) -* 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.9.0 ================== New Features --------------------- From 32c245bceaee4d5f60b9087638dd3b15ba4ca5d2 Mon Sep 17 00:00:00 2001 From: David Smiley Date: Mon, 2 Jun 2025 00:04:47 -0400 Subject: [PATCH 12/12] CHANGES.txt --- solr/CHANGES.txt | 3 +++ 1 file changed, 3 insertions(+) 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 ---------------------