Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-4005: If CoreContainer fails to register a created core, it should close it.

Mark Robert Miller9370f3584f97
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0f1b44d767a..5689312943c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -129,6 +129,10 @@ Bug Fixes
Directory outstanding, we need to wait for them to be released before closing.
(Mark Miller)
+* SOLR-4005: If CoreContainer fails to register a created core, it should close it.
+ (Mark Miller)
+
+
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
index 7dd315d506a..99089886f83 100644
--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java
+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java
@@ -482,6 +482,7 @@ public class CoreContainer
for (int i=0; i<nodes.getLength(); i++) {
Node node = nodes.item(i);
+ SolrCore core = null;
try {
String rawName = DOMUtil.getAttr(node, CORE_NAME, null);
if (null == rawName) {
@@ -526,7 +527,7 @@ public class CoreContainer
p.setCoreProperties(readProperties(cfg, node));
- SolrCore core = create(p);
+ core = create(p);
register(name, core, false);
// track original names
@@ -534,6 +535,9 @@ public class CoreContainer
}
catch (Throwable ex) {
SolrException.log(log,null,ex);
+ if (core != null) {
+ core.close();
+ }
}
}
}