SOLR-6647: Bad error message when missing resource from ZK when parsing Schema

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1633969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jan Høydahl 2014-10-23 22:15:03 +00:00
parent 3deda56ac9
commit 7c3703a5b2
3 changed files with 22 additions and 3 deletions

View File

@ -262,6 +262,8 @@ Bug Fixes
* SOLR-6646: bin/solr start script fails to detect solr on non-default port and then after
30s tails wrong log file (janhoy)
* SOLR-6647: Bad error message when missing resource from ZK when parsing Schema (janhoy)
Optimizations
----------------------

View File

@ -29,6 +29,7 @@ import org.apache.solr.common.cloud.Slice;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.SolrResourceLoader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -84,4 +85,18 @@ public class CloudUtil {
}
}
}
/**
* Returns a displayable unified path to the given resource. For non-solrCloud that will be the
* same as getConfigDir, but for Cloud it will be getCollectionZkPath ending in a /
* <p/>
* <b>Note:</b> Do not use this to generate a valid file path, but for debug printing etc
* @param loader Resource loader instance
* @return a String of path to resource
*/
public static String unifiedResourcePath(SolrResourceLoader loader) {
return (loader instanceof ZkSolrResourceLoader) ?
((ZkSolrResourceLoader) loader).getCollectionZkPath() + "/" :
loader.getConfigDir();
}
}

View File

@ -28,6 +28,7 @@ import org.apache.lucene.index.StoredDocument;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.uninverting.UninvertingReader;
import org.apache.lucene.util.Version;
import org.apache.solr.cloud.CloudUtil;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.SolrParams;
@ -445,7 +446,8 @@ public class IndexSchema {
}
protected void readSchema(InputSource is) {
log.info("Reading Solr Schema from " + resourceName);
String resourcePath = CloudUtil.unifiedResourcePath(loader) + resourceName;
log.info("Reading Solr Schema from " + resourcePath);
try {
// pass the config resource loader to avoid building an empty one for no reason:
@ -594,11 +596,11 @@ public class IndexSchema {
}
} catch (SolrException e) {
throw new SolrException(ErrorCode.getErrorCode(e.code()), e.getMessage() + ". Schema file is " +
loader.getConfigDir() + resourceName, e);
resourcePath, e);
} catch(Exception e) {
// unexpected exception...
throw new SolrException(ErrorCode.SERVER_ERROR,
"Schema Parsing Failed: " + e.getMessage() + ". Schema file is " + loader.getConfigDir() + resourceName,
"Schema Parsing Failed: " + e.getMessage() + ". Schema file is " + resourcePath,
e);
}