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) {
|
if (newLoader != classLoader) {
|
||||||
this.classLoader = newLoader;
|
this.classLoader = newLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("[{}] Added {} libs to classloader, from paths: {}",
|
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("/")))
|
.map(u -> u.getPath().substring(0,u.getPath().lastIndexOf("/")))
|
||||||
.sorted()
|
.sorted()
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toList()));
|
.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>
|
* 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
|
* 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();
|
final XPath xpath = schemaConf.getXPath();
|
||||||
String expression = stepsToPath(SCHEMA, AT + NAME);
|
String expression = stepsToPath(SCHEMA, AT + NAME);
|
||||||
Node nd = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
|
Node nd = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);
|
||||||
|
String coreName = getCoreName("null");
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
// Another case where the initialization from the test harness is different than the "real world"
|
// Another case where the initialization from the test harness is different than the "real world"
|
||||||
sb.append("[");
|
sb.append("[");
|
||||||
if (loader.getCoreProperties() != null) {
|
sb.append(coreName);
|
||||||
sb.append(loader.getCoreProperties().getProperty(SOLR_CORE_NAME));
|
|
||||||
} else {
|
|
||||||
sb.append("null");
|
|
||||||
}
|
|
||||||
sb.append("] ");
|
sb.append("] ");
|
||||||
if (nd==null) {
|
if (nd==null) {
|
||||||
sb.append("schema has no name!");
|
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.",
|
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
|
// /schema/solrQueryParser/@defaultOperator
|
||||||
|
@ -550,7 +547,7 @@ public class IndexSchema {
|
||||||
isExplicitQueryParserDefaultOperator = true;
|
isExplicitQueryParserDefaultOperator = true;
|
||||||
queryParserDefaultOperator=node.getNodeValue().trim();
|
queryParserDefaultOperator=node.getNodeValue().trim();
|
||||||
log.info("[{}] query parser default operator is {}. WARNING: Deprecated, please use 'q.op' on request instead.",
|
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()
|
// /schema/uniqueKey/text()
|
||||||
|
@ -580,7 +577,7 @@ public class IndexSchema {
|
||||||
uniqueKeyFieldName=uniqueKeyField.getName();
|
uniqueKeyFieldName=uniqueKeyField.getName();
|
||||||
uniqueKeyFieldType=uniqueKeyField.getType();
|
uniqueKeyFieldType=uniqueKeyField.getType();
|
||||||
log.info("[{}] unique key field: {}",
|
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
|
// Unless the uniqueKeyField is marked 'required=false' then make sure it exists
|
||||||
if( Boolean.FALSE != explicitRequiredProp.get( uniqueKeyFieldName ) ) {
|
if( Boolean.FALSE != explicitRequiredProp.get( uniqueKeyFieldName ) ) {
|
||||||
|
@ -611,6 +608,14 @@ public class IndexSchema {
|
||||||
refreshAnalyzers();
|
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() {
|
protected void postReadInform() {
|
||||||
//Run the callbacks on SchemaAware now that everything else is done
|
//Run the callbacks on SchemaAware now that everything else is done
|
||||||
for (SchemaAware aware : schemaAware) {
|
for (SchemaAware aware : schemaAware) {
|
||||||
|
|
Loading…
Reference in New Issue