Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-864 -- DataImportHandler does not catch and log Errors

Shalin Shekhar Mangara788efe7892b
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;
/**
- * <p>
- * 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.
- * </p>
+ * <p> 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. </p>
* <p/>
* <b>This API is experimental and subject to change</b>
*
@@ -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 {
}
/**
- * <p>
- * Collects unique keys of all Solr documents for whom one or more source
- * tables have been changed since the last indexed time.
- * </p>
- * <p>
- * 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
- * </p>
+ * <p> Collects unique keys of all Solr documents for whom one or more source tables have been changed since the last
+ * indexed time. </p> <p> 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 </p>
*
- * @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<Map<String, Object>> collectDelta(DataConfig.Entity entity,