Apache Lucene open-source search software
[SOLR-3221] - fixed possible NPE for text variable being null in UIMAUpdateRequestProcessor
Tommaso Teofili7de9508aa52d
diff --git a/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java b/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.javaindex 98c7f55d786..bbf601765bc 100644--- a/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java+++ b/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java@@ -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);