From 1e9bcb7e25a9585284aa431ec6956b57579dbf30 Mon Sep 17 00:00:00 2001 From: Christos Malliaridis Date: Sat, 14 Dec 2024 17:01:53 +0100 Subject: [PATCH 1/3] Fix argument parsing for -D options with multiple values on Windows (cherry picked from commit 44ea44d1fb07019e8bcd56c7a341301566d64deb) --- solr/bin/solr.cmd | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index 6581d14ed4e..feb859e4b10 100755 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -726,15 +726,37 @@ SHIFT goto parse_args :set_passthru -set "PASSTHRU=%~1=%~2" +set "PASSTHRU_KEY=%~1" +set "PASSTHRU_VALUES=" + +SHIFT +:repeat_passthru +set "arg=%~1" +if "%arg%"=="" goto end_passthru +set firstChar=%arg:~0,1% +IF "%firstChar%"=="-" ( + goto end_passthru +) + +if defined PASSTHRU_VALUES ( + set "PASSTHRU_VALUES=%PASSTHRU_VALUES%,%arg%" +) else ( + set "PASSTHRU_VALUES=%arg%" +) +SHIFT +goto repeat_passthru + +:end_passthru +set "PASSTHRU=%PASSTHRU_KEY%=%PASSTHRU_VALUES%" +echo "Passing through %PASSTHRU%" + IF NOT "%SOLR_OPTS%"=="" ( set "SOLR_OPTS=%SOLR_OPTS% %PASSTHRU%" ) ELSE ( set "SOLR_OPTS=%PASSTHRU%" ) set "PASS_TO_RUN_EXAMPLE=%PASSTHRU% !PASS_TO_RUN_EXAMPLE!" -SHIFT -SHIFT + goto parse_args :set_noprompt From 9a6a4abed1167287839249c79272e034fe3887b5 Mon Sep 17 00:00:00 2001 From: Christos Malliaridis Date: Tue, 17 Dec 2024 16:03:22 +0100 Subject: [PATCH 2/3] SOLR-17595: Fix Solr examples for Windows (#2909) * Fix argument parsing for -D options with multiple values on Windows * Fix invalid usage of wildcards in RunExampleTool / PostTool (cherry picked from commit a4229e76771da0125b38204db01ea0934e09c4f4) --- solr/CHANGES.txt | 3 +++ solr/bin/solr.cmd | 1 - solr/core/src/java/org/apache/solr/cli/RunExampleTool.java | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5a63d0beaf2..9b797e36b2b 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -140,6 +140,9 @@ Bug Fixes * SOLR-17586: Print zkcli.sh deprecation msg to stderr, which fixes Solr Operator upload of security.json to zookeeper (Jan Høydahl) +* SOLR-17595: Fix two issues in Solr CLI that prevent Solr from starting with the techproducts example and from + correctly parsing arguments on Windows that start with -D and have multiple values separated by "," or spaces. (Christos Malliaridis) + Dependency Upgrades --------------------- (No changes) diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd index feb859e4b10..af440528d06 100755 --- a/solr/bin/solr.cmd +++ b/solr/bin/solr.cmd @@ -748,7 +748,6 @@ goto repeat_passthru :end_passthru set "PASSTHRU=%PASSTHRU_KEY%=%PASSTHRU_VALUES%" -echo "Passing through %PASSTHRU%" IF NOT "%SOLR_OPTS%"=="" ( set "SOLR_OPTS=%SOLR_OPTS% %PASSTHRU%" diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java index 0b278d13e60..45380f97db9 100644 --- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java +++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java @@ -337,7 +337,9 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception collectionName, "--type", "application/xml", - exampledocsDir.getAbsolutePath() + "/*.xml" + "--filetypes", + "xml", + exampledocsDir.toAbsolutePath().toString() }; PostTool postTool = new PostTool(); CommandLine postToolCli = SolrCLI.parseCmdLine(postTool, args); From caeef753612284aa90a8b7fc02ec669833c3eb21 Mon Sep 17 00:00:00 2001 From: Christos Malliaridis Date: Tue, 17 Dec 2024 16:08:23 +0100 Subject: [PATCH 3/3] Fix unsupported method --- solr/core/src/java/org/apache/solr/cli/RunExampleTool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java index 45380f97db9..a9afa3be2db 100644 --- a/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java +++ b/solr/core/src/java/org/apache/solr/cli/RunExampleTool.java @@ -339,7 +339,7 @@ protected void runExample(CommandLine cli, String exampleName) throws Exception "application/xml", "--filetypes", "xml", - exampledocsDir.toAbsolutePath().toString() + exampledocsDir.getAbsolutePath() }; PostTool postTool = new PostTool(); CommandLine postToolCli = SolrCLI.parseCmdLine(postTool, args);