[SOLR-3221] - fixed possible NPE for text variable being null in UIMAUpdateRequestProcessor

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1347817 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tommaso Teofili 2012-06-07 22:00:47 +00:00
parent 211f9c77b7
commit 7de9508aa5
1 changed files with 12 additions and 5 deletions

View File

@ -40,7 +40,6 @@ import java.util.Map;
/**
* Update document(s) to be indexed with UIMA extracted information
*
*
*/
public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
@ -102,16 +101,24 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
new StringBuilder(". ").append(logField).append("=")
.append((String)cmd.getSolrInputDocument().getField(logField).getValue())
.append(", ").toString();
int len = Math.min(text.length(), 100);
int len;
String debugString;
if (text != null && text.length() > 0) {
len = Math.min(text.length(), 100);
debugString = new StringBuilder(" text=\"").append(text.substring(0, len)).append("...\"").toString();
}
else {
debugString = " null text";
}
if (solrUIMAConfiguration.isIgnoreErrors()) {
log.warn(new StringBuilder("skip the text processing due to ")
.append(e.getLocalizedMessage()).append(optionalFieldInfo)
.append(" text=\"").append(text.substring(0, len)).append("...\"").toString());
.append(debugString).toString());
} else {
throw new SolrException(ErrorCode.SERVER_ERROR,
new StringBuilder("processing error: ")
new StringBuilder("processing error ")
.append(e.getLocalizedMessage()).append(optionalFieldInfo)
.append(" text=\"").append(text.substring(0, len)).append("...\"").toString(), e);
.append(debugString).toString(), e);
}
}
super.processAdd(cmd);