You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/com/fasterxml/jackson/core/json/ReaderBasedJsonParser.java
+17
Original file line number
Diff line number
Diff line change
@@ -769,6 +769,7 @@ public final JsonToken nextToken() throws IOException
769
769
case'}':
770
770
// Error: } is not valid at this point; valid closers have
771
771
// been handled earlier
772
+
--_inputPtr; // for correct error reporting
772
773
_reportUnexpectedChar(i, "expected a value");
773
774
case't':
774
775
_matchTrue();
@@ -1455,6 +1456,7 @@ private final JsonToken _parseFloat(int ch, int startPtr, int ptr, boolean neg,
1455
1456
// must be followed by sequence of ints, one minimum
1456
1457
if (fractLen == 0) {
1457
1458
if (!isEnabled(JsonReadFeature.ALLOW_TRAILING_DECIMAL_POINT_FOR_NUMBERS.mappedFeature())) {
1459
+
--_inputPtr; // for correct error reporting
1458
1460
_reportUnexpectedNumberChar(ch, "Decimal point not followed by a digit");
1459
1461
}
1460
1462
}
@@ -1484,6 +1486,7 @@ private final JsonToken _parseFloat(int ch, int startPtr, int ptr, boolean neg,
1484
1486
}
1485
1487
// must be followed by sequence of ints, one minimum
1486
1488
if (expLen == 0) {
1489
+
--_inputPtr; // for correct error reporting
1487
1490
_reportUnexpectedNumberChar(ch, "Exponent indicator not followed by a digit");
1488
1491
}
1489
1492
}
@@ -1644,6 +1647,7 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
1644
1647
// must be followed by sequence of ints, one minimum
1645
1648
if (fractLen == 0) {
1646
1649
if (!isEnabled(JsonReadFeature.ALLOW_TRAILING_DECIMAL_POINT_FOR_NUMBERS.mappedFeature())) {
1650
+
--_inputPtr; // for correct error reporting
1647
1651
_reportUnexpectedNumberChar(c, "Decimal point not followed by a digit");
1648
1652
}
1649
1653
}
@@ -1688,6 +1692,7 @@ private final JsonToken _parseNumber2(boolean neg, int startPtr) throws IOExcept
1688
1692
}
1689
1693
// must be followed by sequence of ints, one minimum
1690
1694
if (expLen == 0) {
1695
+
--_inputPtr; // for correct error reporting
1691
1696
_reportUnexpectedNumberChar(c, "Exponent indicator not followed by a digit");
1692
1697
}
1693
1698
}
@@ -1788,11 +1793,13 @@ protected JsonToken _handleInvalidNumberStart(int ch, final boolean negative, fi
1788
1793
}
1789
1794
}
1790
1795
if (!isEnabled(JsonReadFeature.ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS.mappedFeature()) && hasSign && !negative) {
1796
+
--_inputPtr; // for correct error reporting
1791
1797
_reportUnexpectedNumberChar('+', "JSON spec does not allow numbers to have plus signs: enable `JsonReadFeature.ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS` to allow");
1792
1798
}
1793
1799
finalStringmessage = negative ?
1794
1800
"expected digit (0-9) to follow minus sign, for valid numeric value" :
_reportUnexpectedChar(c, "expected a valid value "+_validJsonValueList());
2795
2804
returnnull;
2796
2805
}
@@ -2923,11 +2932,13 @@ protected JsonToken _handleInvalidNumberStart(int ch, final boolean neg, final b
2923
2932
match);
2924
2933
}
2925
2934
if (!isEnabled(JsonReadFeature.ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS.mappedFeature()) && hasSign && !neg) {
2935
+
--_inputPtr; // for correct error reporting
2926
2936
_reportUnexpectedNumberChar('+', "JSON spec does not allow numbers to have plus signs: enable `JsonReadFeature.ALLOW_LEADING_PLUS_SIGN_FOR_NUMBERS` to allow");
2927
2937
}
2928
2938
finalStringmessage = neg ?
2929
2939
"expected digit (0-9) to follow minus sign, for valid numeric value" :
2930
2940
"expected digit (0-9) for valid numeric value";
2941
+
--_inputPtr; // for correct error reporting
2931
2942
_reportUnexpectedNumberChar(ch, message);
2932
2943
returnnull;
2933
2944
}
@@ -3253,6 +3264,7 @@ private final int _skipColon2(boolean gotColon) throws IOException
3253
3264
returni;
3254
3265
}
3255
3266
if (i != INT_COLON) {
3267
+
--_inputPtr; // for correct error reporting
3256
3268
_reportUnexpectedChar(i, "was expecting a colon to separate field name and value");
3257
3269
}
3258
3270
gotColon = true;
@@ -3275,6 +3287,7 @@ private final int _skipColon2(boolean gotColon) throws IOException
3275
3287
privatefinalvoid_skipComment() throwsIOException
3276
3288
{
3277
3289
if ((_features & FEAT_MASK_ALLOW_JAVA_COMMENTS) == 0) {
3290
+
--_inputPtr; // for correct error reporting
3278
3291
_reportUnexpectedChar('/', "maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)");
3279
3292
}
3280
3293
// First: check which comment (if either) it is:
@@ -3287,6 +3300,7 @@ private final void _skipComment() throws IOException
3287
3300
} elseif (c == INT_ASTERISK) {
3288
3301
_skipCComment();
3289
3302
} else {
3303
+
--_inputPtr; // for correct error reporting
3290
3304
_reportUnexpectedChar(c, "was expecting either '*' or '/' for a comment");
0 commit comments