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
This commit is contained in:
Koji Sekiguchi 2011-06-10 01:16:08 +00:00
parent 3ad6ba55d5
commit 739efd5913
3 changed files with 35 additions and 5 deletions

View File

@ -24,8 +24,12 @@ $Id$
(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 ==================

View File

@ -89,15 +89,16 @@ public class UIMAUpdateRequestProcessor extends UpdateRequestProcessor {
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);

View File

@ -24,6 +24,7 @@ import java.util.HashMap;
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 @@ public class UIMAUpdateRequestProcessorTest extends SolrTestCaseJ4 {
+ " 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 {