@@ -211,7 +211,7 @@ public int releaseBuffered(Writer w) throws IOException {
211
211
protected char getNextChar (String eofMsg ) throws IOException {
212
212
return getNextChar (eofMsg , null );
213
213
}
214
-
214
+
215
215
protected char getNextChar (String eofMsg , JsonToken forToken ) throws IOException {
216
216
if (_inputPtr >= _inputEnd ) {
217
217
if (!_loadMore ()) {
@@ -1576,6 +1576,7 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
1576
1576
int intLen = 0 ;
1577
1577
char c = (_inputPtr < _inputEnd ) ? _inputBuffer [_inputPtr ++]
1578
1578
: getNextChar ("No digit following minus sign" , JsonToken .VALUE_NUMBER_INT );
1579
+
1579
1580
if (c == '0' ) {
1580
1581
c = _verifyNoLeadingZeroes ();
1581
1582
}
@@ -1606,9 +1607,10 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
1606
1607
}
1607
1608
}
1608
1609
1609
- int fractLen = 0 ;
1610
+ int fractLen = - 1 ;
1610
1611
// And then see if we get other parts
1611
1612
if (c == '.' ) { // yes, fraction
1613
+ fractLen = 0 ;
1612
1614
if (outPtr >= outBuf .length ) {
1613
1615
outBuf = _textBuffer .finishCurrentSegment ();
1614
1616
outPtr = 0 ;
@@ -1640,16 +1642,17 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
1640
1642
}
1641
1643
}
1642
1644
1643
- int expLen = 0 ;
1645
+ int expLen = - 1 ;
1644
1646
if (c == 'e' || c == 'E' ) { // exponent?
1647
+ expLen = 0 ;
1645
1648
if (outPtr >= outBuf .length ) {
1646
1649
outBuf = _textBuffer .finishCurrentSegment ();
1647
1650
outPtr = 0 ;
1648
1651
}
1649
1652
outBuf [outPtr ++] = c ;
1650
1653
// Not optional, can require that we get one more char
1651
1654
c = (_inputPtr < _inputEnd ) ? _inputBuffer [_inputPtr ++]
1652
- : getNextChar ("expected a digit for number exponent" );
1655
+ : getNextChar ("expected a digit for number exponent" , JsonToken . VALUE_NUMBER_FLOAT );
1653
1656
// Sign indicator?
1654
1657
if (c == '-' || c == '+' ) {
1655
1658
if (outPtr >= outBuf .length ) {
@@ -1659,7 +1662,7 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
1659
1662
outBuf [outPtr ++] = c ;
1660
1663
// Likewise, non optional:
1661
1664
c = (_inputPtr < _inputEnd ) ? _inputBuffer [_inputPtr ++]
1662
- : getNextChar ("expected a digit for number exponent" );
1665
+ : getNextChar ("expected a digit for number exponent" , JsonToken . VALUE_NUMBER_FLOAT );
1663
1666
}
1664
1667
1665
1668
exp_loop :
@@ -1690,8 +1693,14 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
1690
1693
}
1691
1694
}
1692
1695
_textBuffer .setCurrentLength (outPtr );
1696
+
1693
1697
// And there we have it!
1694
- return reset (neg , intLen , fractLen , expLen );
1698
+ // 26-Jun-2022, tatu: Careful here, as non-standard numbers can
1699
+ // cause surprises - cannot use plain "reset()" but apply diff logic
1700
+ if (fractLen < 0 && expLen < 0 ) { // integer
1701
+ return resetInt (neg , intLen );
1702
+ }
1703
+ return resetFloat (neg , intLen , fractLen , expLen );
1695
1704
}
1696
1705
1697
1706
// Method called when we have seen one zero, and want to ensure
0 commit comments