diff --git a/avro/src/main/java/tools/jackson/dataformat/avro/deser/AvroParserImpl.java b/avro/src/main/java/tools/jackson/dataformat/avro/deser/AvroParserImpl.java index 9e19b0fb8..b1bdb04ec 100644 --- a/avro/src/main/java/tools/jackson/dataformat/avro/deser/AvroParserImpl.java +++ b/avro/src/main/java/tools/jackson/dataformat/avro/deser/AvroParserImpl.java @@ -205,13 +205,10 @@ public final void _initSchema(AvroSchema schema) throws JacksonException { public final boolean isNaN() { if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) { if ((_numTypesValid & NR_DOUBLE) != 0) { - // 10-Mar-2017, tatu: Alas, `Double.isFinite(d)` only added in JDK 8 - double d = _numberDouble; - return Double.isNaN(d) || Double.isInfinite(d); + return !Double.isFinite(_numberDouble); } if ((_numTypesValid & NR_FLOAT) != 0) { - float f = _numberFloat; - return Float.isNaN(f) || Float.isInfinite(f); + return !Float.isFinite(_numberFloat); } } return false; diff --git a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java index c2a046594..6792f96bb 100644 --- a/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java +++ b/cbor/src/main/java/tools/jackson/dataformat/cbor/CBORParser.java @@ -1988,13 +1988,10 @@ private final byte[] _getBinaryFromString(Base64Variant variant) throws JacksonE public boolean isNaN() { if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) { if ((_numTypesValid & NR_DOUBLE) != 0) { - // 10-Mar-2017, tatu: Alas, `Double.isFinite(d)` only added in JDK 8 - double d = _numberDouble; - return Double.isNaN(d) || Double.isInfinite(d); + return !Double.isFinite(_numberDouble); } if ((_numTypesValid & NR_FLOAT) != 0) { - float f = _numberFloat; - return Float.isNaN(f) || Float.isInfinite(f); + return !Float.isFinite(_numberFloat); } } return false; diff --git a/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java b/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java index 8fda4e7d0..d2c536864 100644 --- a/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java +++ b/protobuf/src/main/java/tools/jackson/dataformat/protobuf/ProtobufParser.java @@ -1577,13 +1577,10 @@ public int readBinaryValue(Base64Variant b64variant, OutputStream out) throws Ja public boolean isNaN() { if (_currToken == JsonToken.VALUE_NUMBER_FLOAT) { if ((_numTypesValid & NR_DOUBLE) != 0) { - // 10-Mar-2017, tatu: Alas, `Double.isFinite(d)` only added in JDK 8 - double d = _numberDouble; - return Double.isNaN(d) || Double.isInfinite(d); + return !Double.isFinite(_numberDouble); } if ((_numTypesValid & NR_FLOAT) != 0) { - float f = _numberFloat; - return Float.isNaN(f) || Float.isInfinite(f); + return !Float.isFinite(_numberFloat); } } return false; diff --git a/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java b/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java index 119329dc7..c7e8287f1 100644 --- a/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java +++ b/smile/src/main/java/tools/jackson/dataformat/smile/SmileParserBase.java @@ -350,14 +350,11 @@ public final boolean isNaN() throws JacksonException { if (_numTypesValid == NR_UNKNOWN) { _parseNumericValue(); // will also check event type } - if (_numberType == NumberType.DOUBLE) { - // 10-Mar-2017, tatu: Alas, `Double.isFinite(d)` only added in JDK 8 - double d = _numberDouble; - return Double.isNaN(d) || Double.isInfinite(d); + if ((_numTypesValid & NR_DOUBLE) != 0) { + return !Double.isFinite(_numberDouble); } - if (_numberType == NumberType.FLOAT) { - float f = _numberFloat; - return Float.isNaN(f) || Float.isInfinite(f); + if ((_numTypesValid & NR_FLOAT) != 0) { + return !Float.isFinite(_numberFloat); } } return false;