Skip to content

Commit f028bb2

Browse files
committed
Merge branch '2.18' into 2.19
2 parents 5ce9464 + 5ccb155 commit f028bb2

File tree

3 files changed

+18
-6
lines changed

3 files changed

+18
-6
lines changed

release-notes/VERSION-2.x

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ a pure JSON library.
4747
(requested by Ilenia S)
4848
(fixed by @pjfanning)
4949

50+
2.18.5 (not yet released)
51+
52+
#1433: `JsonParser#getNumberType()` throws `JsonParseException` when
53+
the current token is non-numeric instead of returning null
54+
(reported by @CrazySqueak)
55+
5056
2.18.4 (06-May-2025)
5157

5258
No changes since 2.18.3

src/main/java/com/fasterxml/jackson/core/JsonParser.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,12 +1778,18 @@ public Object getNumberValueDeferred() throws IOException {
17781778
* If current token is of type
17791779
* {@link JsonToken#VALUE_NUMBER_INT} or
17801780
* {@link JsonToken#VALUE_NUMBER_FLOAT}, returns
1781-
* one of {@link NumberType} constants; otherwise returns {@code null}.
1781+
* one of {@link NumberType} constants; otherwise throws
1782+
* a {@link JsonParseException}.
1783+
*<p>
1784+
* NOTE: before 2.18 was documented to return {@code null} for non-numeric
1785+
* tokens, but this has never been the case.
17821786
*
1783-
* @return Type of current number, if parser points to numeric token; {@code null} otherwise
1787+
* @return Type of current number, if parser points to numeric token.
17841788
*
1785-
* @throws IOException for low-level read issues, or
1786-
* {@link JsonParseException} for decoding problems
1789+
* @throws IOException {@link JsonParseException} if
1790+
* the current token is not numeric, or if decoding of the value fails
1791+
* (invalid format for numbers); plain {@link IOException} if underlying
1792+
* content read fails (possible if numbers are decoded lazily).
17871793
*/
17881794
public abstract NumberType getNumberType() throws IOException;
17891795

src/test/java/com/fasterxml/jackson/core/read/NumberParsingTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
@SuppressWarnings("resource")
2424
class NumberParsingTest
25-
extends JUnit5TestBase
25+
extends JUnit5TestBase
2626
{
2727
protected JsonFactory jsonFactory() {
2828
return sharedStreamFactory();
@@ -33,7 +33,7 @@ protected JsonFactory jsonFactory() {
3333

3434
/*
3535
/**********************************************************************
36-
/* Tests, Boolean
36+
/* Tests, Boolean (why here?)
3737
/**********************************************************************
3838
*/
3939

0 commit comments

Comments
 (0)