Skip to content

Commit be336df

Browse files
committed
Merge branch '2.x' into 3.x
2 parents 601efdb + f9b2ff4 commit be336df

2 files changed

Lines changed: 14 additions & 22 deletions

File tree

src/main/java/tools/jackson/dataformat/xml/deser/FromXmlParser.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -953,18 +953,18 @@ public boolean isNaN() {
953953

954954
@Override
955955
public NumberType getNumberType() {
956-
if (_numTypesValid == NR_UNKNOWN) {
957-
_checkNumericValue(NR_UNKNOWN); // will also check event type
958-
}
959-
// Only integer types supported so...
960-
961-
if ((_numTypesValid & NR_INT) != 0) {
962-
return NumberType.INT;
963-
}
964-
if ((_numTypesValid & NR_LONG) != 0) {
965-
return NumberType.LONG;
956+
if (_numTypesValid != NR_UNKNOWN) {
957+
// Only integer types supported (via `isExpectedNumberIntToken
958+
if ((_numTypesValid & NR_INT) != 0) {
959+
return NumberType.INT;
960+
}
961+
if ((_numTypesValid & NR_LONG) != 0) {
962+
return NumberType.LONG;
963+
}
964+
return NumberType.BIG_INTEGER;
966965
}
967-
return NumberType.BIG_INTEGER;
966+
// 31-May-2025, tatu: [core#1434] Return null for unknown in 3.0
967+
return null;
968968
}
969969

970970
@Override

src/test/java/tools/jackson/dataformat/xml/deser/XmlNumberParsingGetType1433Test.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
import org.junit.jupiter.api.Test;
44

55
import tools.jackson.core.*;
6-
import tools.jackson.core.exc.StreamReadException;
76

87
import tools.jackson.dataformat.xml.*;
98

10-
import static org.junit.jupiter.api.Assertions.assertNull;
119
import static org.junit.jupiter.api.Assertions.assertEquals;
10+
import static org.junit.jupiter.api.Assertions.assertNull;
1211
import static org.junit.jupiter.api.Assertions.assertTrue;
13-
import static org.junit.jupiter.api.Assertions.fail;
1412

1513
public class XmlNumberParsingGetType1433Test
1614
extends XmlTestUtil
@@ -35,20 +33,14 @@ void getNumberType() throws Exception
3533
assertEquals(JsonParser.NumberType.INT, p.getNumberType());
3634
assertToken(JsonToken.END_OBJECT, p.nextToken());
3735
_verifyGetNumberTypeFail(p, "END_OBJECT");
38-
assertNull(p.nextToken());
39-
_verifyGetNumberTypeFail(p, "null");
4036
p.close();
4137
_verifyGetNumberTypeFail(p, "null");
4238
}
4339

4440
private void _verifyGetNumberTypeFail(JsonParser p, String token) throws Exception
4541
{
46-
try {
47-
p.getNumberType();
48-
fail("Should not pass");
49-
} catch (StreamReadException e) {
50-
verifyException(e, "Current token ("+token+") not numeric, cannot use numeric");
51-
}
42+
// In 2.x got exception; in 3.x null
43+
assertNull(p.getNumberType());
5244
}
5345

5446
private JsonParser _createParser(String text) throws Exception {

0 commit comments

Comments
 (0)