From 46d60dadb4faf142100161dc0c8d6dad7b2a30a6 Mon Sep 17 00:00:00 2001 From: Erick Erickson Date: Mon, 18 Aug 2014 18:55:09 +0000 Subject: [PATCH] SOLR-6338: coreRootDirectory requires trailing slash, or SolrCloud cores are created in wrong location. Thanks Primoz git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1618705 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ solr/core/src/java/org/apache/solr/core/ConfigSolr.java | 2 +- solr/core/src/test/org/apache/solr/core/TestSolrXml.java | 6 +++--- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 711012ab9df..d5794f3d322 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -289,6 +289,9 @@ Bug Fixes Java bug #8047340 to SystemInfoHandler: On Turkish default locale, some JVMs fail to fork on MacOSX, BSD, AIX, and Solaris platforms. (hossman, Uwe Schindler) +* SOLR-6338: coreRootDirectory requires trailing slash, or SolrCloud cores are created in wrong location. + (Primož Skale via Erick Erickson) + Optimizations --------------------- diff --git a/solr/core/src/java/org/apache/solr/core/ConfigSolr.java b/solr/core/src/java/org/apache/solr/core/ConfigSolr.java index 36a24d3127b..fd48580690d 100644 --- a/solr/core/src/java/org/apache/solr/core/ConfigSolr.java +++ b/solr/core/src/java/org/apache/solr/core/ConfigSolr.java @@ -105,7 +105,7 @@ public abstract class ConfigSolr { * @return core root directory */ public String getCoreRootDirectory() { - return get(CfgProp.SOLR_COREROOTDIRECTORY, config.getResourceLoader().getInstanceDir()); + return SolrResourceLoader.normalizeDir( get(CfgProp.SOLR_COREROOTDIRECTORY, config.getResourceLoader().getInstanceDir()) ); } public PluginInfo getShardHandlerFactoryPluginInfo() { diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java index 590c98bc47e..19b0e601fad 100644 --- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java +++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java @@ -69,7 +69,7 @@ public class TestSolrXml extends SolrTestCaseJ4 { assertEquals("collection handler class", "testCollectionsHandler", cfg.getCollectionsHandlerClass()); assertEquals("info handler class", "testInfoHandler", cfg.getInfoHandlerClass()); assertEquals("core load threads", 11, cfg.getCoreLoadThreadCount()); - assertEquals("core root dir", "testCoreRootDirectory", cfg.getCoreRootDirectory()); + assertEquals("core root dir", "testCoreRootDirectory" + File.separator, cfg.getCoreRootDirectory()); assertEquals("distrib conn timeout", 22, cfg.getDistributedConnectionTimeout()); assertEquals("distrib socket timeout", 33, cfg.getDistributedSocketTimeout()); assertEquals("max update conn", 3, cfg.getMaxUpdateConnections()); @@ -95,7 +95,7 @@ public class TestSolrXml extends SolrTestCaseJ4 { // Test a few property substitutions that happen to be in solr-50-all.xml. public void testPropertySub() throws IOException { - System.setProperty("coreRootDirectory", "myCoreRoot"); + System.setProperty("coreRootDirectory", "myCoreRoot" + File.separator); System.setProperty("hostPort", "8888"); System.setProperty("shareSchema", "false"); System.setProperty("socketTimeout", "220"); @@ -105,7 +105,7 @@ public class TestSolrXml extends SolrTestCaseJ4 { FileUtils.copyFile(new File(testSrcRoot, "solr-50-all.xml"), new File(solrHome, "solr.xml")); ConfigSolr cfg = ConfigSolr.fromSolrHome(loader, solrHome.getAbsolutePath()); - assertEquals("core root dir", "myCoreRoot", cfg.getCoreRootDirectory()); + assertEquals("core root dir", "myCoreRoot" + File.separator, cfg.getCoreRootDirectory()); assertEquals("zk host port", "8888", cfg.getZkHostPort()); assertEquals("schema cache", false, cfg.hasSchemaCache()); }