mirror of https://github.com/apache/lucene.git
SOLR-1678 Move onError handling to DIH framework
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@892775 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d7d599221d
commit
5be5c31bb0
|
@ -33,6 +33,8 @@ New Features
|
|||
|
||||
* SOLR-1654 : TikaEntityProcessor example added DIHExample (Akshay Ukey via noble)
|
||||
|
||||
* SOLR-1678 : Move onError handling to DIH framework (noble)
|
||||
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
|
|
@ -123,12 +123,7 @@ public class TikaEntityProcessor extends EntityProcessorBase {
|
|||
try {
|
||||
tikaParser.parse(is, contentHandler, metadata , new ParseContext());
|
||||
} catch (Exception e) {
|
||||
if(ABORT.equals(onError)){
|
||||
wrapAndThrow(SEVERE, e, "Unable to read content");
|
||||
} else {
|
||||
LOG.warn("Unable to parse document "+ context.getResolvedEntityAttribute(URL) ,e);
|
||||
return null;
|
||||
}
|
||||
wrapAndThrow(SEVERE, e, "Unable to read content");
|
||||
}
|
||||
IOUtils.closeQuietly(is);
|
||||
for (Map<String, String> field : context.getAllEntityFields()) {
|
||||
|
|
|
@ -232,7 +232,18 @@ public class EntityProcessorWrapper extends EntityProcessor {
|
|||
return getFromRowCache();
|
||||
}
|
||||
while (true) {
|
||||
Map<String, Object> arow = delegate.nextRow();
|
||||
Map<String, Object> arow = null;
|
||||
try {
|
||||
arow = delegate.nextRow();
|
||||
} catch (Exception e) {
|
||||
if(ABORT.equals(onError)){
|
||||
wrapAndThrow(SEVERE, e);
|
||||
} else {
|
||||
//SKIP is not really possible. If this calls the nextRow() again the Entityprocessor would be in an inconisttent state
|
||||
log.error("Exception in entity : "+ entityName, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (arow == null) {
|
||||
return null;
|
||||
} else {
|
||||
|
|
|
@ -53,10 +53,7 @@ public class PlainTextEntityProcessor extends EntityProcessorBase {
|
|||
try {
|
||||
r = ds.getData(url);
|
||||
} catch (Exception e) {
|
||||
if (ABORT.equals(onError)) {
|
||||
wrapAndThrow(SEVERE, e, "Exception reading url : " + url);
|
||||
}
|
||||
return null;
|
||||
wrapAndThrow(SEVERE, e, "Exception reading url : " + url);
|
||||
}
|
||||
StringWriter sw = new StringWriter();
|
||||
char[] buf = new char[1024];
|
||||
|
@ -65,12 +62,8 @@ public class PlainTextEntityProcessor extends EntityProcessorBase {
|
|||
try {
|
||||
len = r.read(buf);
|
||||
} catch (IOException e) {
|
||||
if (ABORT.equals(onError)) {
|
||||
wrapAndThrow(SEVERE, e, "Exception reading url : " + url);
|
||||
} else {
|
||||
LOG.warn("IOException while reading from data source", e);
|
||||
return null;
|
||||
}
|
||||
IOUtils.closeQuietly(r);
|
||||
wrapAndThrow(SEVERE, e, "Exception reading url : " + url);
|
||||
}
|
||||
if (len <= 0) break;
|
||||
sw.append(new String(buf, 0, len));
|
||||
|
|
Loading…
Reference in New Issue