Skip to content

Commit 1fac75c

Browse files
authored
remove problematic bigint optimisation (#987)
1 parent 97b13e6 commit 1fac75c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/main/java/com/fasterxml/jackson/core/io/NumberInput.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,6 @@
1414
*/
1515
public final class NumberInput
1616
{
17-
// numbers with more than these characters are better parsed with BigDecimalParser
18-
// parsing numbers with many digits in Java is slower than O(n)
19-
20-
// 04-Apr-2023, tatu: NOTE! This is above default "longest number by chars"
21-
// limit
22-
private final static int LARGE_INT_SIZE = 1250;
23-
2417
/**
2518
* Formerly used constant for a value that was problematic on certain
2619
* pre-1.8 JDKs.
@@ -496,9 +489,6 @@ public static BigDecimal parseBigDecimal(final char[] ch, final boolean useFastP
496489
* @since v2.14
497490
*/
498491
public static BigInteger parseBigInteger(final String s) throws NumberFormatException {
499-
if (s.length() > LARGE_INT_SIZE) {
500-
return BigDecimalParser.parse(s).toBigInteger();
501-
}
502492
return new BigInteger(s);
503493
}
504494

src/test/java/com/fasterxml/jackson/core/io/BigIntegerParserTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
public class BigIntegerParserTest extends com.fasterxml.jackson.core.BaseTest {
44

5+
public void testFastParseBigIntegerFailsWithENotation() {
6+
String num = "2e308";
7+
try {
8+
BigIntegerParser.parseWithFastParser(num);
9+
fail("expected NumberFormatException");
10+
} catch (NumberFormatException nfe) {
11+
// expected
12+
}
13+
}
14+
515
public void testLongStringFastParseBigInteger() {
616
try {
717
BigIntegerParser.parseWithFastParser(genLongString());

0 commit comments

Comments
 (0)