lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomm...@apache.org
Subject svn commit: r1347817 - /lucene/dev/trunk/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
Date Thu, 07 Jun 2012 22:00:48 GMT
Author: tommaso
Date: Thu Jun  7 22:00:47 2012
New Revision: 1347817

URL: http://svn.apache.org/viewvc?rev=1347817&view=rev
Log:
[SOLR-3221] - fixed possible NPE for text variable being null in UIMAUpdateRequestProcessor

Modified:
    lucene/dev/trunk/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java

Modified: lucene/dev/trunk/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java?rev=1347817&r1=1347816&r2=1347817&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
(original)
+++ lucene/dev/trunk/solr/contrib/uima/src/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
Thu Jun  7 22:00:47 2012
@@ -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 
         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);



Mime
View raw message