Skip to content

Commit 6224569

Browse files
authored
Fix #4435 (or rather, mark as fixed; fix via jackson-core) (#4446)
1 parent fe42cf7 commit 6224569

File tree

3 files changed

+38
-65
lines changed

3 files changed

+38
-65
lines changed

release-notes/VERSION-2.x

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ Project: jackson-databind
1212

1313
#4428: `ByteBuddy` scope went beyond `test` in version 2.17.0
1414
(reported by Miguel M-R)
15-
(fix contributed by Joo-Hyuk K)
15+
(fix by Joo-Hyuk K)
16+
#4435: Cannot deserialize value of type `java.math.BigDecimal` from
17+
String ".05": not a valid representation
18+
(reported by @EAlf91)
19+
(fix by @pjfanning)
1620

1721
2.17.0 (12-Mar-2024)
1822

@@ -99,7 +103,7 @@ Project: jackson-databind
99103
100104
#1770: Incorrect deserialization for `BigDecimal` numbers
101105
(reported by @cristian-mocanu-mob)
102-
(fix contributed by @pjfanning)
106+
(fix by @pjfanning)
103107
#2502: Add a way to configure caches Jackson uses
104108
(contributed by Joo-Hyuk K)
105109
#2787: Mix-ins do not work for `Enum`s

src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigDecimalDeser4435Test.java

-57
This file was deleted.

src/test/java/com/fasterxml/jackson/databind/deser/BigNumbersDeserTest.java renamed to src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigNumbersDeserTest.java

+32-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.fasterxml.jackson.databind.deser;
1+
package com.fasterxml.jackson.databind.deser.jdk;
22

33
import java.math.BigDecimal;
44
import java.math.BigInteger;
@@ -11,15 +11,14 @@
1111

1212
import com.fasterxml.jackson.databind.ObjectMapper;
1313
import com.fasterxml.jackson.databind.json.JsonMapper;
14-
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil.DoubleWrapper;
14+
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;
1515

16+
import static org.junit.jupiter.api.Assertions.assertEquals;
1617
import static org.junit.jupiter.api.Assertions.assertNotNull;
1718
import static org.junit.jupiter.api.Assertions.fail;
1819

19-
import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.newJsonMapper;
20-
import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.verifyException;
21-
2220
public class BigNumbersDeserTest
21+
extends DatabindTestUtil
2322
{
2423
static class BigIntegerWrapper {
2524
public BigInteger number;
@@ -31,7 +30,7 @@ static class BigDecimalWrapper {
3130

3231
/*
3332
/**********************************************************
34-
/* Tests
33+
/* Test methods
3534
/**********************************************************
3635
*/
3736

@@ -103,6 +102,33 @@ public void testBigIntegerUnlimited() throws Exception
103102
assertNotNull(bdw);
104103
}
105104

105+
// [databind#4435]
106+
@Test
107+
public void testNumberStartingWithDot() throws Exception
108+
{
109+
String num = ".555555555555555555555555555555";
110+
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
111+
assertEquals(new BigDecimal(num), w.number);
112+
}
113+
114+
// [databind#4435]
115+
@Test
116+
public void testNumberStartingWithMinusDot() throws Exception
117+
{
118+
String num = "-.555555555555555555555555555555";
119+
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
120+
assertEquals(new BigDecimal(num), w.number);
121+
}
122+
123+
// [databind#4435]
124+
@Test
125+
public void testNumberStartingWithPlusDot() throws Exception
126+
{
127+
String num = "+.555555555555555555555555555555";
128+
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
129+
assertEquals(new BigDecimal(num), w.number);
130+
}
131+
106132
private String generateJson(final String fieldName) {
107133
final int len = 1200;
108134
final StringBuilder sb = new StringBuilder();

0 commit comments

Comments
 (0)