Skip to content

Commit 33ba784

Browse files
committed
Fix #61
1 parent a37ada0 commit 33ba784

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

avro/src/main/java/com/fasterxml/jackson/dataformat/avro/AvroParser.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.fasterxml.jackson.dataformat.avro;
22

33
import java.io.IOException;
4-
import java.io.InputStream;
54
import java.io.Writer;
65
import java.math.BigDecimal;
76

@@ -262,9 +261,11 @@ public JsonLocation getCurrentLocation()
262261
protected void convertNumberToBigDecimal() throws IOException {
263262
// ParserBase uses _textValue instead of _numberDouble for some reason when NR_DOUBLE is set, but _textValue is not set by setNumber()
264263
// Catch and use _numberDouble instead
265-
if ((_numTypesValid & NR_DOUBLE) != 0 && _textValue == null) {
266-
_numberBigDecimal = BigDecimal.valueOf(_numberDouble);
267-
return;
264+
if ((_numTypesValid & NR_DOUBLE) != 0) {
265+
if (_textValue == null) {
266+
_numberBigDecimal = BigDecimal.valueOf(_numberDouble);
267+
return;
268+
}
268269
}
269270
super.convertNumberToBigDecimal();
270271
}

protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufParser.java

+12
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,18 @@ protected void _checkNumericValue(int expType) throws IOException
16401640
_reportError("Current token ("+_currToken+") not numeric, can not use numeric value accessors");
16411641
}
16421642

1643+
@Override // since 2.9
1644+
public boolean isNaN() {
1645+
if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) {
1646+
if ((_numTypesValid & NR_DOUBLE) != 0) {
1647+
// 10-Mar-2017, tatu: Alas, `Double.isFinite(d)` only added in JDK 8
1648+
double d = _numberDouble;
1649+
return Double.isNaN(d) || Double.isInfinite(d);
1650+
}
1651+
}
1652+
return false;
1653+
}
1654+
16431655
protected void convertNumberToInt() throws IOException
16441656
{
16451657
// First, converting from long ought to be easy

0 commit comments

Comments
 (0)