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

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1629305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tomas Eduardo Fernandez Lobbe 2014-10-03 20:16:59 +00:00
parent c44e4ee0ff
commit 26c9773c6c
3 changed files with 13 additions and 8 deletions

View File

@ -203,6 +203,8 @@ Bug Fixes
* SOLR-6530: Commits under network partitions can put any node in down state. * SOLR-6530: Commits under network partitions can put any node in down state.
(Ramkumar Aiyengar, Alan Woodward, Mark Miller, shalin) (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 Other Changes
---------------------- ----------------------

View File

@ -21,6 +21,7 @@ package org.apache.solr.core;
import org.apache.lucene.index.IndexDeletionPolicy; import org.apache.lucene.index.IndexDeletionPolicy;
import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.util.Version; import org.apache.lucene.util.Version;
import org.apache.solr.cloud.ZkSolrResourceLoader;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode; import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.handler.component.SearchComponent; import org.apache.solr.handler.component.SearchComponent;
@ -144,7 +145,12 @@ public class SolrConfig extends Config {
return new SolrConfig(loader, name, null); return new SolrConfig(loader, name, null);
} }
catch (Exception e) { 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); throw new SolrException(ErrorCode.SERVER_ERROR, "Error loading solr config from " + resource, e);
} }
} }

View File

@ -17,9 +17,7 @@ package org.apache.solr.cloud;
* limitations under the License. * limitations under the License.
*/ */
import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.util.LuceneTestCase.Slow; import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException; import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.ModifiableSolrParams; 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.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest; import org.apache.solr.request.LocalSolrQueryRequest;
import org.apache.solr.request.SolrQueryRequest; 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.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
@ -151,12 +147,13 @@ public class BasicZkTest extends AbstractZkTestCase {
// we set the solrconfig to nothing, so this reload should fail // we set the solrconfig to nothing, so this reload should fail
try { try {
SolrTestCaseJ4.ignoreException("SolrException"); ignoreException("solrconfig.xml");
h.getCoreContainer().reload(h.getCore().getName()); h.getCoreContainer().reload(h.getCore().getName());
SolrTestCaseJ4.resetExceptionIgnores();
fail("The reloaded SolrCore did not pick up configs from zookeeper"); fail("The reloaded SolrCore did not pick up configs from zookeeper");
} catch(SolrException e) { } 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 // test stats call