Apache Lucene open-source search software
SOLR-7037: bin/solr start -e techproducts -c fails to start Solr in cloud mode
Timothy Potter9c1e05d60496
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 7da07dac24f..1b188028cc5 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -556,6 +556,9 @@ Bug Fixes* SOLR-7038: Validate the presence of configset before trying to create a collection.(Anshum Gupta, Mark Miller)+* SOLR-7037: bin/solr start -e techproducts -c fails to start Solr in cloud mode+ (Timothy Potter)+Optimizations----------------------diff --git a/solr/bin/solr b/solr/bin/solrindex 4ce235d8e16..08166181959 100755--- a/solr/bin/solr+++ b/solr/bin/solr@@ -1022,6 +1022,7 @@ if [ "$EXAMPLE" != "" ]; thenmkdir -p $SOLR_HOMEif [ ! -f "$SOLR_HOME/solr.xml" ]; thencp $DEFAULT_SERVER_DIR/solr/solr.xml $SOLR_HOME/solr.xml+ cp $DEFAULT_SERVER_DIR/solr/zoo.cfg $SOLR_HOME/zoo.cfgfiEXAMPLE_CONFIGSET=sample_techproducts_configsshift@@ -1035,6 +1036,7 @@ if [ "$EXAMPLE" != "" ]; thenmkdir -p $SOLR_HOMEif [ ! -f "$SOLR_HOME/solr.xml" ]; thencp $DEFAULT_SERVER_DIR/solr/solr.xml $SOLR_HOME/solr.xml+ cp $DEFAULT_SERVER_DIR/solr/zoo.cfg $SOLR_HOME/zoo.cfgfiEXAMPLE_CONFIGSET=data_driven_schema_configsshiftdiff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmdindex 74f98975090..5073d441a4a 100644--- a/solr/bin/solr.cmd+++ b/solr/bin/solr.cmd@@ -569,6 +569,9 @@ IF "%EXAMPLE%"=="" (IF NOT EXIST "!SOLR_HOME!\solr.xml" (copy "%DEFAULT_SERVER_DIR%\solr\solr.xml" "!SOLR_HOME!\solr.xml")+ IF NOT EXIST "!SOLR_HOME!\zoo.cfg" (+ copy "%DEFAULT_SERVER_DIR%\solr\zoo.cfg" "!SOLR_HOME!\zoo.cfg"+ )) ELSE IF "%EXAMPLE%"=="cloud" (set SOLR_MODE=solrcloudgoto cloud_example_start@@ -580,6 +583,9 @@ IF "%EXAMPLE%"=="" (IF NOT EXIST "!SOLR_HOME!\solr.xml" (copy "%DEFAULT_SERVER_DIR%\solr\solr.xml" "!SOLR_HOME!\solr.xml")+ IF NOT EXIST "!SOLR_HOME!\zoo.cfg" (+ copy "%DEFAULT_SERVER_DIR%\solr\zoo.cfg" "!SOLR_HOME!\zoo.cfg"+ )) ELSE (@echo.@echo 'Unrecognized example %EXAMPLE%!'diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.javaindex 527f860f8ce..e02b97a6699 100644--- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java+++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java@@ -478,7 +478,16 @@ public class SolrCLI {public Map<String,Object> handleResponse(HttpResponse response) throws ClientProtocolException, IOException {HttpEntity entity = response.getEntity();if (entity != null) {- Object resp = ObjectBuilder.getVal(new JSONParser(EntityUtils.toString(entity)));++ String respBody = EntityUtils.toString(entity);+ Object resp = null;+ try {+ resp = ObjectBuilder.getVal(new JSONParser(respBody));+ } catch (JSONParser.ParseException pe) {+ throw new ClientProtocolException("Expected JSON response from server but received: "+respBody++ "\nTypically, this indicates a problem with the Solr server; check the Solr server logs for more information.");+ }+if (resp != null && resp instanceof Map) {return (Map<String,Object>)resp;} else {@@ -1495,13 +1504,17 @@ public class SolrCLI {int result = -1;Tool tool = null;try {- Map<String,Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);+ Map<String, Object> systemInfo = getJson(httpClient, systemInfoUrl, 2);if ("solrcloud".equals(systemInfo.get("mode"))) {tool = new CreateCollectionTool();} else {tool = new CreateCoreTool();}result = tool.runTool(cli);+ } catch (Exception exc) {+ System.err.println("ERROR: create failed due to: "+exc.getMessage());+ System.err.println();+ result = 1;} finally {closeHttpClient(httpClient);}