From e340bce86d66e8c54e79ef4a4add19fd51ab9c8c Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Wed, 24 Jun 2009 10:25:15 +0000 Subject: [PATCH] SOLR-1214 followup -- Fix root cause of test failures by setting solrHome correctly for different scenarios git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@787967 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/solr/core/CoreContainer.java | 14 +++++--------- src/java/org/apache/solr/util/TestHarness.java | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/java/org/apache/solr/core/CoreContainer.java b/src/java/org/apache/solr/core/CoreContainer.java index 22e3ccb194a..9741c16ffa8 100644 --- a/src/java/org/apache/solr/core/CoreContainer.java +++ b/src/java/org/apache/solr/core/CoreContainer.java @@ -72,14 +72,10 @@ public class CoreContainer protected Map indexSchemaCache; protected String adminHandler; protected boolean shareSchema; - protected final String solrHome; + protected String solrHome; - @Deprecated public CoreContainer() { - solrHome ="."; - } - public CoreContainer(String home) { - solrHome =home; + solrHome = SolrResourceLoader.locateSolrHome(); } public Properties getContainerProperties() { @@ -115,7 +111,7 @@ public class CoreContainer log.info("looking for solr.xml: " + fconf.getAbsolutePath()); if (fconf.exists()) { - cores = new CoreContainer(solrHome); + cores = new CoreContainer(); cores.load(solrHome, fconf); abortOnConfigurationError = false; // if any core aborts on startup, then abort @@ -153,7 +149,6 @@ public class CoreContainer */ public CoreContainer(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException { - solrHome = dir; this.load(dir, configFile); } @@ -163,7 +158,7 @@ public class CoreContainer */ public CoreContainer(SolrResourceLoader loader) { this.loader = loader; - solrHome = loader.getInstanceDir(); + this.solrHome = loader.getInstanceDir(); } //------------------------------------------------------------------- @@ -181,6 +176,7 @@ public class CoreContainer public void load(String dir, File configFile ) throws ParserConfigurationException, IOException, SAXException { this.configFile = configFile; this.loader = new SolrResourceLoader(dir); + solrHome = loader.getInstanceDir(); FileInputStream cfgis = new FileInputStream(configFile); try { Config cfg = new Config(loader, null, cfgis, null); diff --git a/src/java/org/apache/solr/util/TestHarness.java b/src/java/org/apache/solr/util/TestHarness.java index ba86f151c32..a06672a1575 100644 --- a/src/java/org/apache/solr/util/TestHarness.java +++ b/src/java/org/apache/solr/util/TestHarness.java @@ -175,7 +175,7 @@ public class TestHarness { } @Override public CoreContainer initialize() { - CoreContainer container = new CoreContainer(new SolrResourceLoader(SolrResourceLoader.locateInstanceDir())); + CoreContainer container = new CoreContainer(new SolrResourceLoader(SolrResourceLoader.locateSolrHome())); CoreDescriptor dcore = new CoreDescriptor(container, coreName, solrConfig.getResourceLoader().getInstanceDir()); dcore.setConfigName(solrConfig.getResourceName()); dcore.setSchemaName(indexSchema.getResourceName());