diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index dd6ab3b85dd..61e0a614bae 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -522,6 +522,9 @@ Other Changes * SOLR-8269: Upgrade commons-collections to 3.2.2. This fixes a known serialization vulnerability (janhoy) +* SOLR-8246: Fix SolrCLI to clean the config directory in case creating a core failed. + (Jason Gerlowski via Shai Erera) + ================== 5.3.1 ================== Bug Fixes diff --git a/solr/core/src/java/org/apache/solr/util/SolrCLI.java b/solr/core/src/java/org/apache/solr/util/SolrCLI.java index ec49dba1a05..454ea5ee62c 100644 --- a/solr/core/src/java/org/apache/solr/util/SolrCLI.java +++ b/solr/core/src/java/org/apache/solr/util/SolrCLI.java @@ -1573,7 +1573,7 @@ public class SolrCLI { throw new IllegalArgumentException("\n"+configSetDir.getAbsolutePath()+" doesn't contain a conf subdirectory or solrconfig.xml\n"); } } - echo("\nSetup new core instance directory:\n" + coreInstanceDir.getAbsolutePath()); + echo("\nCopying configuration to new core instance directory:\n" + coreInstanceDir.getAbsolutePath()); } String createCoreUrl = @@ -1585,12 +1585,17 @@ public class SolrCLI { echo("\nCreating new core '" + coreName + "' using command:\n" + createCoreUrl + "\n"); - Map json = getJson(createCoreUrl); - - CharArr arr = new CharArr(); - new JSONWriter(arr, 2).write(json); - echo(arr.toString()); - echo("\n"); + try { + Map json = getJson(createCoreUrl); + CharArr arr = new CharArr(); + new JSONWriter(arr, 2).write(json); + echo(arr.toString()); + echo("\n"); + } catch (Exception e) { + /* create-core failed, cleanup the copied configset before propagating the error. */ + FileUtils.deleteDirectory(coreInstanceDir); + throw e; + } } } // end CreateCoreTool class