mirror of https://github.com/apache/lucene.git
SOLR-6677: Fix test failures related to nullpointer when printing core name in logs.
(cherry picked from commit bede7ae
- which btw had wrong JIRA number..)
This commit is contained in:
parent
97bb81db1a
commit
dffbefa153
|
@ -198,14 +198,23 @@ public class SolrResourceLoader implements ResourceLoader,Closeable
|
|||
if (newLoader != classLoader) {
|
||||
this.classLoader = newLoader;
|
||||
}
|
||||
|
||||
log.info("[{}] Added {} libs to classloader, from paths: {}",
|
||||
getCoreProperties().getProperty(SOLR_CORE_NAME), urls.size(), urls.stream()
|
||||
getCoreName("null"), urls.size(), urls.stream()
|
||||
.map(u -> u.getPath().substring(0,u.getPath().lastIndexOf("/")))
|
||||
.sorted()
|
||||
.distinct()
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
private String getCoreName(String defaultVal) {
|
||||
if (getCoreProperties() != null) {
|
||||
return getCoreProperties().getProperty(SOLR_CORE_NAME, defaultVal);
|
||||
} else {
|
||||
return defaultVal;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds URLs to the ResourceLoader's internal classloader. This method <b>MUST</b>
|
||||
* only be called prior to using this ResourceLoader to get any resources, otherwise
|
||||
|
|
|
@ -462,14 +462,11 @@ public class IndexSchema {
|
|||
final XPath xpath = schemaConf.getXPath();
|
||||
String expression = stepsToPath(SCHEMA, AT + NAME);
|
||||
Node nd = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
|
||||
String coreName = getCoreName("null");
|
||||
StringBuilder sb = new StringBuilder();
|
||||
// Another case where the initialization from the test harness is different than the "real world"
|
||||
sb.append("[");
|
||||
if (loader.getCoreProperties() != null) {
|
||||
sb.append(loader.getCoreProperties().getProperty(SOLR_CORE_NAME));
|
||||
} else {
|
||||
sb.append("null");
|
||||
}
|
||||
sb.append(coreName);
|
||||
sb.append("] ");
|
||||
if (nd==null) {
|
||||
sb.append("schema has no name!");
|
||||
|
@ -538,7 +535,7 @@ public class IndexSchema {
|
|||
}
|
||||
}
|
||||
log.info("[{}] default search field in schema is {}. WARNING: Deprecated, please use 'df' on request instead.",
|
||||
loader.getCoreProperties().getProperty(SOLR_CORE_NAME), defaultSearchFieldName);
|
||||
coreName, defaultSearchFieldName);
|
||||
}
|
||||
|
||||
// /schema/solrQueryParser/@defaultOperator
|
||||
|
@ -550,7 +547,7 @@ public class IndexSchema {
|
|||
isExplicitQueryParserDefaultOperator = true;
|
||||
queryParserDefaultOperator=node.getNodeValue().trim();
|
||||
log.info("[{}] query parser default operator is {}. WARNING: Deprecated, please use 'q.op' on request instead.",
|
||||
loader.getCoreProperties().getProperty(SOLR_CORE_NAME), queryParserDefaultOperator);
|
||||
coreName, queryParserDefaultOperator);
|
||||
}
|
||||
|
||||
// /schema/uniqueKey/text()
|
||||
|
@ -580,7 +577,7 @@ public class IndexSchema {
|
|||
uniqueKeyFieldName=uniqueKeyField.getName();
|
||||
uniqueKeyFieldType=uniqueKeyField.getType();
|
||||
log.info("[{}] unique key field: {}",
|
||||
loader.getCoreProperties().getProperty(SOLR_CORE_NAME), uniqueKeyFieldName);
|
||||
coreName, uniqueKeyFieldName);
|
||||
|
||||
// Unless the uniqueKeyField is marked 'required=false' then make sure it exists
|
||||
if( Boolean.FALSE != explicitRequiredProp.get( uniqueKeyFieldName ) ) {
|
||||
|
@ -610,7 +607,15 @@ public class IndexSchema {
|
|||
// create the field analyzers
|
||||
refreshAnalyzers();
|
||||
}
|
||||
|
||||
|
||||
private String getCoreName(String defaultVal) {
|
||||
if (loader != null && loader.getCoreProperties() != null) {
|
||||
return loader.getCoreProperties().getProperty(SOLR_CORE_NAME, defaultVal);
|
||||
} else {
|
||||
return defaultVal;
|
||||
}
|
||||
}
|
||||
|
||||
protected void postReadInform() {
|
||||
//Run the callbacks on SchemaAware now that everything else is done
|
||||
for (SchemaAware aware : schemaAware) {
|
||||
|
|
Loading…
Reference in New Issue