lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From romseyg...@apache.org
Subject svn commit: r1601758 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/core/ConfigSetService.java core/src/test/org/apache/solr/core/TestConfigSets.java
Date Tue, 10 Jun 2014 19:48:12 GMT
Author: romseygeek
Date: Tue Jun 10 19:48:11 2014
New Revision: 1601758

URL: http://svn.apache.org/r1601758
Log:
SOLR-6158: Fix configSetBaseDir path resolution

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestConfigSets.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1601758&r1=1601757&r2=1601758&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Jun 10 19:48:11 2014
@@ -163,6 +163,9 @@ Bug Fixes
 * SOLR-6146: Incorrect configuration such as wrong chroot in zk server address can
   cause CloudSolrServer to leak resources. (Jessica Cheng, Varun Thacker, shalin)
 
+* SOLR-6158: Relative configSetBase directories were resolved relative to the 
+  container CWD, rather than solr.home. (Simon Endele, Alan Woodward)
+
 Other Changes
 ---------------------
 

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/ConfigSetService.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/ConfigSetService.java?rev=1601758&r1=1601757&r2=1601758&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/ConfigSetService.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/core/ConfigSetService.java Tue Jun
10 19:48:11 2014
@@ -113,7 +113,7 @@ public abstract class ConfigSetService {
    */
   public static class Default extends ConfigSetService {
 
-    private final String configSetBase;
+    private final File configSetBase;
 
     /**
      * Create a new ConfigSetService.Default
@@ -122,7 +122,19 @@ public abstract class ConfigSetService {
      */
     public Default(SolrResourceLoader loader, String configSetBase) {
       super(loader);
-      this.configSetBase = configSetBase;
+      this.configSetBase = resolveBaseDirectory(loader, configSetBase);
+    }
+
+    private File resolveBaseDirectory(SolrResourceLoader loader, String configSetBase) {
+      File csBase = new File(configSetBase);
+      if (!csBase.isAbsolute())
+        csBase = new File(loader.getInstanceDir(), configSetBase);
+      return csBase;
+    }
+
+    // for testing
+    File getConfigSetBase() {
+      return this.configSetBase;
     }
 
     @Override

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestConfigSets.java?rev=1601758&r1=1601757&r2=1601758&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestConfigSets.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/core/TestConfigSets.java Tue Jun 10
19:48:11 2014
@@ -17,14 +17,7 @@ package org.apache.solr.core;
  * limitations under the License.
  */
 
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.core.Is.is;
-import static org.junit.internal.matchers.StringContains.containsString;
-
-import java.io.File;
-import java.io.IOException;
-
+import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.SolrTestCaseJ4;
 import org.junit.Rule;
@@ -32,7 +25,13 @@ import org.junit.Test;
 import org.junit.rules.RuleChain;
 import org.junit.rules.TestRule;
 
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
+import java.io.File;
+import java.io.IOException;
+
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.core.Is.is;
+import static org.junit.internal.matchers.StringContains.containsString;
 
 public class TestConfigSets extends SolrTestCaseJ4 {
 
@@ -54,6 +53,16 @@ public class TestConfigSets extends Solr
   }
 
   @Test
+  public void testDefaultConfigSetBasePathResolution() throws IOException {
+    try (SolrResourceLoader loader = new SolrResourceLoader("/path/to/solr/home")) {
+      ConfigSetService.Default relativeCSS = new ConfigSetService.Default(loader, "configsets");
+      assertThat(relativeCSS.getConfigSetBase().getAbsolutePath(), is("/path/to/solr/home/configsets"));
+      ConfigSetService.Default absoluteCSS = new ConfigSetService.Default(loader, "/path/to/configsets");
+      assertThat(absoluteCSS.getConfigSetBase().getAbsolutePath(), is("/path/to/configsets"));
+    }
+  }
+
+  @Test
   public void testConfigSetServiceFindsConfigSets() {
     CoreContainer container = null;
     SolrCore core1 = null;



Mime
View raw message