Apache Lucene open-source search software
SOLR-2127: Fixed serialization of default core and indentation of solr.xml when serializing.
Mark Robert Miller22f0fe971845
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 232f8799d7e..af783ce5d5d 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -158,6 +158,8 @@ Bug Fixesdealing with SolrDocumentList objects -- ie: sharded queries.(Antonio Verni via hossman)+* SOLR-2127: Fixed serialization of default core and indentation of solr.xml when serializing.+ (Ephraim Ofir, Mark Miller)Other Changes----------------------diff --git a/solr/src/java/org/apache/solr/core/CoreContainer.java b/solr/src/java/org/apache/solr/core/CoreContainer.javaindex 2ea9b9255bb..c26d66737bf 100644--- a/solr/src/java/org/apache/solr/core/CoreContainer.java+++ b/solr/src/java/org/apache/solr/core/CoreContainer.java@@ -879,7 +879,7 @@ public class CoreContainer/** Write the cores configuration through a writer.*/void persist(Writer w) throws IOException {- w.write("<?xml version='1.0' encoding='UTF-8'?>");+ w.write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");w.write("<solr");if (this.libDir != null) {writeAttribute(w,"sharedLib",libDir);@@ -888,9 +888,9 @@ public class CoreContainerw.write(">\n");if (containerProperties != null && !containerProperties.isEmpty()) {- writeProperties(w, containerProperties);+ writeProperties(w, containerProperties, " ");}- w.write("<cores");+ w.write(" <cores");writeAttribute(w, "adminPath",adminPath);if(adminHandler != null) writeAttribute(w, "adminHandler",adminHandler);if(shareSchema) writeAttribute(w, "shareSchema","true");@@ -903,7 +903,7 @@ public class CoreContainer}}- w.write("</cores>\n");+ w.write(" </cores>\n");w.write("</solr>\n");}@@ -918,8 +918,8 @@ public class CoreContainer/** Writes the cores configuration node for a given core. */void persist(Writer w, CoreDescriptor dcore) throws IOException {- w.write(" <core");- writeAttribute(w,"name",dcore.name);+ w.write(" <core");+ writeAttribute(w,"name",dcore.name.equals("") ? defaultCoreName : dcore.name);writeAttribute(w,"instanceDir",dcore.getInstanceDir());//write config (if not default)String opt = dcore.getConfigName();@@ -953,14 +953,14 @@ public class CoreContainerw.write("/>\n"); // coreelse {w.write(">\n");- writeProperties(w, dcore.getCoreProperties());- w.write("</core>");+ writeProperties(w, dcore.getCoreProperties(), " ");+ w.write(" </core>\n");}}- private void writeProperties(Writer w, Properties props) throws IOException {+ private void writeProperties(Writer w, Properties props, String indent) throws IOException {for (Map.Entry<Object, Object> entry : props.entrySet()) {- w.write("<property");+ w.write(indent + "<property");writeAttribute(w,"name",entry.getKey());writeAttribute(w,"value",entry.getValue());w.write("/>\n");