janhoy commented on code in PR #5047:
URL: https://github.com/apache/solr/pull/5047#discussion_r4207897457


##########
solr/core/src/java/org/apache/solr/cli/ConnectionOptions.java:
##########
@@ -73,4 +76,78 @@ String effectiveSolrUrl() throws IOException {
     }
     return solrUrl;
   }
+
+  static String resolveSolrUrl(ConnectionOptions connectionOptions, String 
credentials)
+      throws Exception {
+    if (connectionOptions != null) {
+      String solrUrl = connectionOptions.effectiveSolrUrl();
+      if (solrUrl != null) {
+        return CLIUtils.normalizeSolrUrl(solrUrl);
+      }
+      String zkHost = connectionOptions.effectiveZkHost();
+      if (zkHost != null) {
+        return CLIUtils.solrUrlFromConnection(
+            CloudSolrClient.CloudSolrClientConnection.parse(zkHost), 
credentials);
+      }
+    }
+
+    String solrConnectionProp = EnvUtils.getProperty("solr-connection");
+    if (solrConnectionProp != null && !solrConnectionProp.isBlank()) {
+      var connection = 
CloudSolrClient.CloudSolrClientConnection.parse(solrConnectionProp);
+      if (connection.isZookeeper()) {
+        return CLIUtils.solrUrlFromConnection(connection, credentials);
+      }
+      return CLIUtils.normalizeSolrUrl(connection.quorumItems().get(0));
+    }
+
+    String zkHostProp = EnvUtils.getProperty("zkHost");
+    if (zkHostProp != null && !zkHostProp.isBlank()) {
+      return CLIUtils.solrUrlFromConnection(
+          CloudSolrClient.CloudSolrClientConnection.parse(zkHostProp), 
credentials);
+    }
+
+    String defaultUrl = CLIUtils.getDefaultSolrUrl();
+    CLIO.err(
+        "Neither --solr-connection, --zk-host or --solr-url parameters, nor 
SOLR_CONNECTION, ZK_HOST env var provided, so assuming solr url is "
+            + defaultUrl
+            + ".");
+    return defaultUrl;
+  }
+
+  static String resolveZkHost(
+      ConnectionOptions connectionOptions, String solrUrl, String credentials) 
throws Exception {
+    if (connectionOptions != null) {
+      String zkHost = connectionOptions.effectiveZkHost();
+      if (zkHost != null) {
+        return zkHost;
+      }
+    }
+
+    String solrConnectionProp = EnvUtils.getProperty("solr-connection");

Review Comment:
   Yes, it's been a bug for some time, and this may have thus been a copy-paste 
bug.
   
   Wrt maintenance, all of the ref-guide pages you see in these PRs are fully 
auto-generated based on the autoritative Java Picocli annotations, and thus 
nothing to maintain - they will reflect the code 100%. If a Tool is deleted, 
the page will disappear. If a typo is fixed in a Picocli annotation, the 
refguide page will be generated too..



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to