SOLR-2579: UIMAUpdateRequestProcessor ignore error fails if text.length() < 100

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1134163 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/solr/contrib/uima/CHANGES.txt b/solr/contrib/uima/CHANGES.txt
index 72b4972..80b3c50 100644
--- a/solr/contrib/uima/CHANGES.txt
+++ b/solr/contrib/uima/CHANGES.txt
@@ -24,8 +24,12 @@
 (No Changes)
 
 ==================  3.3.0-dev ==============
+  
+Bug Fixes
+----------------------
 
-(No Changes)
+* SOLR-2579: UIMAUpdateRequestProcessor ignore error fails if text.length() < 100.
+  (Elmer Garduno via koji)
 
 ==================  3.2.0 ==================
 
diff --git a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
index 69d8d93..f0aa2b2 100644
--- a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
+++ b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessor.java
@@ -89,15 +89,16 @@
         new StringBuilder(". ").append(logField).append("=")
         .append((String)cmd.getSolrInputDocument().getField(logField).getValue())
         .append(", ").toString();
-      if (solrUIMAConfiguration.isIgnoreErrors())
+      int len = Math.min(text.length(), 100);
+      if (solrUIMAConfiguration.isIgnoreErrors()) {
         log.warn(new StringBuilder("skip the text processing due to ")
           .append(e.getLocalizedMessage()).append(optionalFieldInfo)
-          .append(" text=\"").append(text.substring(0, 100)).append("...\"").toString());
-      else{
+          .append(" text=\"").append(text.substring(0, len)).append("...\"").toString());
+      } else {
         throw new SolrException(ErrorCode.SERVER_ERROR,
             new StringBuilder("processing error: ")
               .append(e.getLocalizedMessage()).append(optionalFieldInfo)
-              .append(" text=\"").append(text.substring(0, 100)).append("...\"").toString(), e);
+              .append(" text=\"").append(text.substring(0, len)).append("...\"").toString(), e);
       }
     }
     super.processAdd(cmd);
diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java
index b921d15..74164a5 100644
--- a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java
+++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java
@@ -24,6 +24,7 @@
 import java.util.Map;
 
 import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.SolrException;
 import org.apache.solr.common.params.MultiMapSolrParams;
 import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.params.UpdateParams;
@@ -158,6 +159,30 @@
                     + " Last Lucene European Conference has been held in Prague."));
     assertU(commit());
     assertQ(req("*:*"), "//*[@numFound='1']");
+
+    try{
+      addDoc("uima-not-ignoreErrors", adoc(
+            "id",
+            "2312312321312",
+            "text",
+            "SpellCheckComponent got improvement related to recent Lucene changes."));
+      fail("exception shouldn't be ignored");
+    }
+    catch(StringIndexOutOfBoundsException e){  // SOLR-2579
+      fail("exception shouldn't be raised");
+    }
+    catch(SolrException expected){}
+
+    try{
+      addDoc("uima-ignoreErrors", adoc(
+            "id",
+            "2312312321312",
+            "text",
+            "SpellCheckComponent got improvement related to recent Lucene changes."));
+    }
+    catch(StringIndexOutOfBoundsException e){  // SOLR-2579
+      fail("exception shouldn't be raised");
+    }
   }
 
   private void addDoc(String chain, String doc) throws Exception {