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


##########
solr/core/src/java/org/apache/solr/cli/PostTool.java:
##########
@@ -315,8 +320,17 @@ public void runImpl(CommandLine cli) throws Exception {
         throw new IllegalArgumentException(
             "Must specify -c / --name parameter with --solr-url to post 
documents.");
       }
-      String url =
-          SolrCLI.normalizeSolrUrl(cli) + "/solr/" + 
cli.getOptionValue("name") + "/update";
+
+      String solrUrl = cli.getOptionValue("solr-url");
+
+      String hostContext = System.getProperty("hostContext", "/solr");
+      if (hostContext.isBlank()) {
+        log.warn("Invalid hostContext {} provided, setting to /solr", 
hostContext);
+        hostContext = "/solr";
+      }
+
+      solrUrl = SolrCLI.normalizeSolrUrl(solrUrl, true, hostContext) + 
hostContext;

Review Comment:
   I thought of the same workaround, and guess I'm medium happy about it. Would 
of course prefer a `SolrCLI` util method that hides this such as 
`SolrCLI.getAndNormalizeSolrUrl(cli), and consider using it wherever we do raw 
`cli.getOptionValue("solr-url")`, since we'd potentially run into same issue 
elsewhere.



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to