This is an automated email from the ASF dual-hosted git repository.

epugh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 9ca0dbaf766 SOLR-16672: Remove use of setDefaultCollection in SolrCLI 
(#1372)
9ca0dbaf766 is described below

commit 9ca0dbaf7661a7420dac97623d93c30b39db4fd0
Author: Eric Pugh <[email protected]>
AuthorDate: Thu Feb 23 07:56:06 2023 -0500

    SOLR-16672: Remove use of setDefaultCollection in SolrCLI (#1372)
    
    Simplify how the Healthcheck command gets it target collection and 
eradicate an unneeded setDefaultCollection method.
---
 solr/CHANGES.txt                                                   | 2 ++
 solr/core/src/java/org/apache/solr/util/SolrCLI.java               | 7 ++-----
 solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java | 6 ++++++
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index d20115bca00..6e8c731cf7a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -309,6 +309,8 @@ Other Changes
 
 * SOLR-15928: Dim 'Add Collection' and 'Create Alias' buttons when user lacks 
proper permissions (janhoy)
 
+* SOLR-16672: Simplify SolrCLI Healthcheck command's logic for obtaining a 
target collection (Eric Pugh)
+
 ==================  9.1.1 ==================
 
 Bug Fixes
diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java 
b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
index c7112bf6608..546a0f50bca 100755
--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java
+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java
@@ -211,9 +211,6 @@ public class SolrCLI implements CLIO {
           new CloudLegacySolrClient.Builder(Collections.singletonList(zkHost), 
Optional.empty())
               .build()) {
 
-        String collection = cli.getOptionValue("collection");
-        if (collection != null) 
cloudSolrClient.setDefaultCollection(collection);
-
         cloudSolrClient.connect();
         runCloudTool(cloudSolrClient, cli);
       }
@@ -592,7 +589,7 @@ public class SolrCLI implements CLIO {
    * Tries a simple HEAD request and throws SolrException in case of 
Authorization error
    *
    * @param url the url to do a HEAD request to
-   * @param httpClient the http client to use (make sure it has authentication 
optinos set)
+   * @param httpClient the http client to use (make sure it has authentication 
options set)
    * @return the HTTP response code
    * @throws SolrException if auth/autz problems
    * @throws IOException if connection failure
@@ -1273,7 +1270,7 @@ public class SolrCLI implements CLIO {
 
       SolrQuery q = new SolrQuery("*:*");
       q.setRows(0);
-      QueryResponse qr = cloudSolrClient.query(q);
+      QueryResponse qr = cloudSolrClient.query(collection, q);
       String collErr = null;
       long docCount = -1;
       try {
diff --git a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java 
b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
index 320c0000d10..855e85e0c54 100644
--- a/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
+++ b/solr/core/src/test/org/apache/solr/util/TestSolrCLIRunExample.java
@@ -324,6 +324,12 @@ public class TestSolrCLIRunExample extends SolrTestCaseJ4 {
     testExample("schemaless");
   }
 
+  @Test
+  @LuceneTestCase.Nightly
+  public void testFilmsExample() throws Exception {
+    testExample("films");
+  }
+
   protected void testExample(String exampleName) throws Exception {
     File solrHomeDir = new File(ExternalPaths.SERVER_HOME);
     if (!solrHomeDir.isDirectory())

Reply via email to