From a788efe7892b17b894c56c1c12aaeb2cb3ffb201 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Mon, 17 Nov 2008 08:26:29 +0000 Subject: [PATCH] SOLR-864 -- DataImportHandler does not catch and log Errors git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@718187 13f79535-47bb-0310-9956-ffa450edef68 --- contrib/dataimporthandler/CHANGES.txt | 2 ++ .../solr/handler/dataimport/DataImporter.java | 8 +++--- .../solr/handler/dataimport/DocBuilder.java | 27 ++++++++----------- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/contrib/dataimporthandler/CHANGES.txt b/contrib/dataimporthandler/CHANGES.txt index 1687260c739..590ab447299 100644 --- a/contrib/dataimporthandler/CHANGES.txt +++ b/contrib/dataimporthandler/CHANGES.txt @@ -56,6 +56,8 @@ Bug Fixes 6. SOLR-838: The VariableResolver obtained from a DataSource's context does not have current data. (Noble Paul via shalin) +7. SOLR-864: DataImportHandler does not catch and log Errors (shalin) + Documentation ---------------------- diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java index 56f9d623d74..8a361ebe430 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java @@ -337,8 +337,8 @@ public class DataImporter { docBuilder.execute(getConfig().documents.get(0).name); if (!requestParams.debug) cumulativeStatistics.add(docBuilder.importStatistics); - } catch (RuntimeException e) { - LOG.error("Full Import failed", e); + } catch (Throwable t) { + LOG.error("Full Import failed", t); } finally { setStatus(Status.IDLE); config.clearCaches(); @@ -360,8 +360,8 @@ public class DataImporter { docBuilder.execute(config.documents.get(0).name); if (!requestParams.debug) cumulativeStatistics.add(docBuilder.importStatistics); - } catch (RuntimeException e) { - LOG.error("Delta Import Failed", e); + } catch (Throwable t) { + LOG.error("Delta Import Failed", t); } finally { setStatus(Status.IDLE); config.clearCaches(); diff --git a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java index 9d4bb78ab17..68822d6e12b 100644 --- a/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java +++ b/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DocBuilder.java @@ -29,11 +29,8 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; /** - *

- * DocBuilder is responsible for creating Solr documents out of the given - * configuration. It also maintains statistics information. It depends on the - * EntityProcessor implementations to fetch data. - *

+ *

DocBuilder is responsible for creating Solr documents out of the given configuration. It also maintains + * statistics information. It depends on the EntityProcessor implementations to fetch data.

*

* This API is experimental and subject to change * @@ -335,6 +332,11 @@ public class DocBuilder { throw e; } else throw e; + } catch (Throwable t) { + if (verboseDebug) { + writer.log(SolrWriter.ENTITY_EXCEPTION, entity.name, t); + } + throw new DataImportHandlerException(DataImportHandlerException.SEVERE, t); } finally { if (verboseDebug) { writer.log(SolrWriter.ROW_END, entity.name, null); @@ -431,18 +433,11 @@ public class DocBuilder { } /** - *

- * Collects unique keys of all Solr documents for whom one or more source - * tables have been changed since the last indexed time. - *

- *

- * Note: In our definition, unique key of Solr document is the primary key of - * the top level entity (unless skipped using docRoot=false) in the Solr - * document in data-config.xml - *

+ *

Collects unique keys of all Solr documents for whom one or more source tables have been changed since the last + * indexed time.

Note: In our definition, unique key of Solr document is the primary key of the top level + * entity (unless skipped using docRoot=false) in the Solr document in data-config.xml

* - * @return an iterator to the list of keys for which Solr documents should be - * updated. + * @return an iterator to the list of keys for which Solr documents should be updated. */ @SuppressWarnings("unchecked") public Set> collectDelta(DataConfig.Entity entity,