From ad3200b7269af2c744594d87d49c8d4ba634c927 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Sun, 22 Jun 2014 07:48:53 +0000 Subject: [PATCH] SOLR-6165: DataImportHandler should write BigInteger and BigDecimal values as strings git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1604543 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../solr/handler/dataimport/JdbcDataSource.java | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5a7262170b7..e65aae9aa47 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -94,6 +94,9 @@ Bug Fixes * SOLR-6095 : SolrCloud cluster can end up without an overseer with overseer roles (Noble Paul, Shalin Mangar) +* SOLR-6165: DataImportHandler should write BigInteger and BigDecimal values as strings. + (Anand Sengamalai via shalin) + Other Changes --------------------- diff --git a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/JdbcDataSource.java b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/JdbcDataSource.java index ece47dc4536..8c8de28ae90 100644 --- a/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/JdbcDataSource.java +++ b/solr/contrib/dataimporthandler/src/java/org/apache/solr/handler/dataimport/JdbcDataSource.java @@ -25,6 +25,8 @@ import org.slf4j.LoggerFactory; import javax.naming.InitialContext; import javax.naming.NamingException; +import java.math.BigDecimal; +import java.math.BigInteger; import java.sql.*; import java.util.*; import java.util.concurrent.Callable; @@ -313,8 +315,14 @@ public class JdbcDataSource extends for (String colName : colNames) { try { if (!convertType) { - // Use underlying database's type information - result.put(colName, resultSet.getObject(colName)); + // Use underlying database's type information except for BigDecimal and BigInteger + // which cannot be serialized by JavaBin/XML. See SOLR-6165 + Object value = resultSet.getObject(colName); + if (value instanceof BigDecimal || value instanceof BigInteger) { + result.put(colName, value.toString()); + } else { + result.put(colName, value); + } continue; }