Apache Solr open-source search software
SOLR-17625: Remove NamedList.findRecursive
David Smileyeebb3815309b
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java b/solr/solrj/src/java/org/apache/solr/common/util/NamedList.javaindex b59d8c779a5..a56a2784cd0 100644--- a/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java+++ b/solr/solrj/src/java/org/apache/solr/common/util/NamedList.java@@ -328,70 +328,6 @@ public class NamedList<T>}}- /**- * Recursively parses the NamedList structure to arrive at a specific element. As you descend the- * NamedList tree, the last element can be any type, including NamedList, but the previous- * elements MUST be NamedList objects themselves. A null value is returned if the indicated- * hierarchy doesn't exist, but NamedList allows null values so that could be the actual value at- * the end of the path.- *- * <p>This method is particularly useful for parsing the response from Solr's /admin/mbeans- * handler, but it also works for any complex structure.- *- * <p>Explicitly casting the return value is recommended. An even safer option is to accept the- * return value as an object and then check its type.- *- * <p>Usage examples:- *- * <p>String coreName = (String) response.findRecursive ("solr-mbeans", "CORE", "core", "stats",- * "coreName"); long numDoc = (long) response.findRecursive ("solr-mbeans", "CORE", "searcher",- * "stats", "numDocs");- *- * @param args One or more strings specifying the tree to navigate.- * @return the last entry in the given path hierarchy, null if not found.- * @deprecated use {@link org.apache.solr.common.NavigableObject} methods instead- */- @Deprecated- public Object findRecursive(String... args) {- NamedList<?> currentList = null;- Object value = null;- for (int i = 0; i < args.length; i++) {- String key = args[i];- /*- * The first time through the loop, the current list is null, so we assign- * it to this list. Then we retrieve the first key from this list and- * assign it to value.- *- * On the next loop, we check whether the retrieved value is a NamedList.- * If it is, then we drop to that NamedList, grab the value of the- * next key, and start the loop over. If it is not a NamedList, then we- * assign the value to null and break out of the loop.- *- * Assigning the value to null and then breaking out of the loop seems- * like the wrong thing to do, but there's a very simple reason that it- * works: If we have reached the last key, then the loop ends naturally- * after we retrieve the value, and that code is never executed.- */- if (currentList == null) {- currentList = this;- } else {- if (value instanceof NamedList) {- currentList = (NamedList<?>) value;- } else {- value = null;- break;- }- }- /*- * We do not need to do a null check on currentList for the following- * assignment. The instanceof check above will fail if the current list is- * null, and if that happens, the loop will end before this point.- */- value = currentList.get(key, 0);- }- return value;- }-@Overridepublic String toString() {StringBuilder sb = new StringBuilder();