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
This commit is contained in:
Shalin Shekhar Mangar 2014-06-22 07:48:53 +00:00
parent e98bcb8254
commit ad3200b726
2 changed files with 13 additions and 2 deletions

View File

@ -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
---------------------

View File

@ -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;
}