Skip to content

Commit

Permalink
One more change wrt #631
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 10, 2020
1 parent 90379ff commit b795cb8
Showing 1 changed file with 37 additions and 7 deletions.
44 changes: 37 additions & 7 deletions src/main/java/com/fasterxml/jackson/core/base/ParserBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public boolean isNaN() {
/* Numeric accessors of public API
/**********************************************************
*/

@Override
public Number getNumberValue() throws IOException
{
Expand All @@ -599,13 +599,43 @@ public Number getNumberValue() throws IOException
if ((_numTypesValid & NR_BIGINT) != 0) {
return _numberBigInt;
}
// Shouldn't get this far but if we do
_throwInternal();
}

// And then floating point types. But here optimal type
// needs to be big decimal, to avoid losing any data?
if ((_numTypesValid & NR_BIGDECIMAL) != 0) {
return _numberBigDecimal;
}

/* And then floating point types. But here optimal type
* needs to be big decimal, to avoid losing any data?
*/
if ((_numTypesValid & NR_DOUBLE) == 0) { // sanity check
_throwInternal();
}
return _numberDouble;
}

// NOTE: mostly copied from above
@Override
public Number getNumberValueExact() throws IOException
{
if (_currToken == JsonToken.VALUE_NUMBER_INT) {
if (_numTypesValid == NR_UNKNOWN) {
_parseNumericValue(NR_UNKNOWN);
}
if ((_numTypesValid & NR_INT) != 0) {
return _numberInt;
}
if ((_numTypesValid & NR_LONG) != 0) {
return _numberLong;
}
if ((_numTypesValid & NR_BIGINT) != 0) {
return _numberBigInt;
}
_throwInternal();
}
// 09-Jul-2020, tatu: [databind#2644] requires we will retain accuracy, so:
if (_numTypesValid == NR_UNKNOWN) {
_parseNumericValue(NR_BIGDECIMAL);
}
if ((_numTypesValid & NR_BIGDECIMAL) != 0) {
return _numberBigDecimal;
}
Expand Down Expand Up @@ -733,7 +763,7 @@ public BigDecimal getDecimalValue() throws IOException
/* Conversion from textual to numeric representation
/**********************************************************
*/

/**
* Method that will parse actual numeric value out of a syntactically
* valid number value. Type it will parse into depends on whether
Expand Down

0 comments on commit b795cb8

Please sign in to comment.