Skip to content

Apache Lucene open-source search software

SOLR-6587: Correct exception thrown on bad collection configuration in SolrCloud mode

Tomas Eduardo Fernandez Lobbe26c9773c6cf2
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7d7154d2418..1928df3c57a 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -203,6 +203,8 @@ Bug Fixes
* SOLR-6530: Commits under network partitions can put any node in down state.
(Ramkumar Aiyengar, Alan Woodward, Mark Miller, shalin)
+* SOLR-6587: Misleading exception when creating collections in SolrCloud with bad configuration.
+ (Tomás Fernández Löbbe)
Other Changes
----------------------
diff --git a/solr/core/src/java/org/apache/solr/core/SolrConfig.java b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
index a3be91294f9..0c866533d1b 100644
--- a/solr/core/src/java/org/apache/solr/core/SolrConfig.java
+++ b/solr/core/src/java/org/apache/solr/core/SolrConfig.java
@@ -21,6 +21,7 @@ package org.apache.solr.core;
import org.apache.lucene.index.IndexDeletionPolicy;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.util.Version;
+import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.handler.component.SearchComponent;
@@ -144,7 +145,12 @@ public class SolrConfig extends Config {
return new SolrConfig(loader, name, null);
}
catch (Exception e) {
- String resource = loader.getConfigDir() + name;
+ String resource;
+ if (loader instanceof ZkSolrResourceLoader) {
+ resource = name;
+ } else {
+ resource = loader.getConfigDir() + name;
+ }
throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading solr config from " + resource, e);
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java b/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
index 5da0b8fb1ed..fb3db969db2 100644
--- a/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/BasicZkTest.java
@@ -17,9 +17,7 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.util.LuceneTestCase.Slow;
-import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -27,8 +25,6 @@ import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest;
-import org.apache.solr.update.DirectUpdateHandler2;
-import org.apache.solr.util.RefCounted;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -151,12 +147,13 @@ public class BasicZkTest extends AbstractZkTestCase {
// we set the solrconfig to nothing, so this reload should fail
try {
- SolrTestCaseJ4.ignoreException("SolrException");
+ ignoreException("solrconfig.xml");
h.getCoreContainer().reload(h.getCore().getName());
- SolrTestCaseJ4.resetExceptionIgnores();
fail("The reloaded SolrCore did not pick up configs from zookeeper");
} catch(SolrException e) {
-
+ resetExceptionIgnores();
+ assertTrue(e.getMessage().contains("Unable to reload core [collection1]"));
+ assertTrue(e.getCause().getMessage().contains("Error loading solr config from solrconfig.xml"));
}
// test stats call