Skip to content

Commit 3f29ef4

Browse files
authored
support StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER (#3685)
1 parent bca1131 commit 3f29ef4

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/std/NumberDeserializers.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -844,13 +844,14 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx
844844
try {
845845
if (!_isIntNumber(text)) {
846846
if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
847-
return NumberInput.parseBigDecimal(text);
847+
return NumberInput.parseBigDecimal(
848+
text, p.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
848849
}
849850
return Double.valueOf(
850851
NumberInput.parseDouble(text, p.isEnabled(StreamReadFeature.USE_FAST_DOUBLE_PARSER)));
851852
}
852853
if (ctxt.isEnabled(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS)) {
853-
return NumberInput.parseBigInteger(text);
854+
return NumberInput.parseBigInteger(text, p.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
854855
}
855856
long value = NumberInput.parseLong(text);
856857
if (!ctxt.isEnabled(DeserializationFeature.USE_LONG_FOR_INTS)) {
@@ -961,7 +962,7 @@ public BigInteger deserialize(JsonParser p, DeserializationContext ctxt) throws
961962
return getNullValue(ctxt);
962963
}
963964
try {
964-
return NumberInput.parseBigInteger(text);
965+
return NumberInput.parseBigInteger(text, p.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
965966
} catch (IllegalArgumentException iae) { }
966967
return (BigInteger) ctxt.handleWeirdStringValue(_valueClass, text,
967968
"not a valid representation");
@@ -1030,7 +1031,7 @@ public BigDecimal deserialize(JsonParser p, DeserializationContext ctxt)
10301031
return getNullValue(ctxt);
10311032
}
10321033
try {
1033-
return NumberInput.parseBigDecimal(text);
1034+
return NumberInput.parseBigDecimal(text, p.isEnabled(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER));
10341035
} catch (IllegalArgumentException iae) { }
10351036
return (BigDecimal) ctxt.handleWeirdStringValue(_valueClass, text,
10361037
"not a valid representation");

src/test/java/com/fasterxml/jackson/databind/seq/ReadValuesTest.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,13 @@ private void testObjectReaderWithFastDoubleParser(final boolean useParserFeature
371371
if (useParserFeature) {
372372
JsonFactory factory = new JsonFactory();
373373
factory.enable(JsonParser.Feature.USE_FAST_DOUBLE_PARSER);
374+
factory.enable(JsonParser.Feature.USE_FAST_BIG_NUMBER_PARSER);
374375
mapper = JsonMapper.builder(factory).build();
375376
} else {
376-
mapper = JsonMapper.builder().enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER).build();
377+
mapper = JsonMapper.builder()
378+
.enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
379+
.enable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)
380+
.build();
377381
}
378382

379383
final MappingIterator<Map<String, Double>> iterator = mapper.reader().forType(new TypeReference<Map<String, Double>>(){}).readValues(JSON);
@@ -399,9 +403,13 @@ private void testObjectReaderWithFastFloatParser(final boolean useParserFeature)
399403
if (useParserFeature) {
400404
JsonFactory factory = new JsonFactory();
401405
factory.enable(JsonParser.Feature.USE_FAST_DOUBLE_PARSER);
406+
factory.enable(JsonParser.Feature.USE_FAST_BIG_NUMBER_PARSER);
402407
mapper = JsonMapper.builder(factory).build();
403408
} else {
404-
mapper = JsonMapper.builder().enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER).build();
409+
mapper = JsonMapper.builder()
410+
.enable(StreamReadFeature.USE_FAST_DOUBLE_PARSER)
411+
.enable(StreamReadFeature.USE_FAST_BIG_NUMBER_PARSER)
412+
.build();
405413
}
406414
final MappingIterator<Map<String, Float>> iterator = mapper.reader().forType(new TypeReference<Map<String, Float>>(){}).readValues(JSON);
407415

0 commit comments

Comments
 (0)