SOLR-8801: /bin/solr create script always returns exit code 0 when a collection/core already exists

This commit is contained in:
Steve Rowe 2016-05-20 19:36:39 -04:00
parent 25e913211b
commit b4d8e42a1f
3 changed files with 9 additions and 2 deletions

View File

@ -195,6 +195,9 @@ Bug Fixes
* SOLR-9128: Fix error handling issues in Streaming classes (Joel Bernstein) * SOLR-9128: Fix error handling issues in Streaming classes (Joel Bernstein)
* SOLR-8801: /bin/solr create script always returns exit code 0 when a collection/core already exists.
(Khalid Alharbi, Marius Grama via Steve Rowe)
Optimizations Optimizations
---------------------- ----------------------
* SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation. * SOLR-8722: Don't force a full ZkStateReader refresh on every Overseer operation.

View File

@ -1642,7 +1642,7 @@ public class SolrCLI {
String systemInfoUrl = solrUrl+"admin/info/system"; String systemInfoUrl = solrUrl+"admin/info/system";
CloseableHttpClient httpClient = getHttpClient(); CloseableHttpClient httpClient = getHttpClient();
Tool tool = null; ToolBase tool = null;
try { try {
Map<String, Object> systemInfo = getJson(httpClient, systemInfoUrl, 2, true); Map<String, Object> systemInfo = getJson(httpClient, systemInfoUrl, 2, true);
if ("solrcloud".equals(systemInfo.get("mode"))) { if ("solrcloud".equals(systemInfo.get("mode"))) {
@ -1650,7 +1650,7 @@ public class SolrCLI {
} else { } else {
tool = new CreateCoreTool(stdout); tool = new CreateCoreTool(stdout);
} }
tool.runTool(cli); tool.runImpl(cli);
} finally { } finally {
closeHttpClient(httpClient); closeHttpClient(httpClient);
} }

View File

@ -93,6 +93,10 @@ public class SolrCloudExampleTest extends AbstractFullDistribZkTestBase {
ensureAllReplicasAreActive(testCollectionName, "shard2", 2, 2, 10); ensureAllReplicasAreActive(testCollectionName, "shard2", 2, 2, 10);
cloudClient.setDefaultCollection(testCollectionName); cloudClient.setDefaultCollection(testCollectionName);
int invalidToolExitStatus = 1;
assertEquals("Collection '" + testCollectionName + "' created even though it already existed",
invalidToolExitStatus, tool.runTool(cli));
// now index docs like bin/post would do but we can't use SimplePostTool because it uses System.exit when // now index docs like bin/post would do but we can't use SimplePostTool because it uses System.exit when
// it encounters an error, which JUnit doesn't like ... // it encounters an error, which JUnit doesn't like ...
log.info("Created collection, now posting example docs!"); log.info("Created collection, now posting example docs!");