Skip to content

Commit

Permalink
Fix #4435 (or rather, mark as fixed; fix via jackson-core) (#4446)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder authored Mar 23, 2024
1 parent fe42cf7 commit 6224569
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 65 deletions.
8 changes: 6 additions & 2 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ Project: jackson-databind

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

2.17.0 (12-Mar-2024)

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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fasterxml.jackson.databind.deser;
package com.fasterxml.jackson.databind.deser.jdk;

import java.math.BigDecimal;
import java.math.BigInteger;
Expand All @@ -11,15 +11,14 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil.DoubleWrapper;
import com.fasterxml.jackson.databind.testutil.DatabindTestUtil;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.fail;

import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.newJsonMapper;
import static com.fasterxml.jackson.databind.testutil.DatabindTestUtil.verifyException;

public class BigNumbersDeserTest
extends DatabindTestUtil
{
static class BigIntegerWrapper {
public BigInteger number;
Expand All @@ -31,7 +30,7 @@ static class BigDecimalWrapper {

/*
/**********************************************************
/* Tests
/* Test methods
/**********************************************************
*/

Expand Down Expand Up @@ -103,6 +102,33 @@ public void testBigIntegerUnlimited() throws Exception
assertNotNull(bdw);
}

// [databind#4435]
@Test
public void testNumberStartingWithDot() throws Exception
{
String num = ".555555555555555555555555555555";
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
assertEquals(new BigDecimal(num), w.number);
}

// [databind#4435]
@Test
public void testNumberStartingWithMinusDot() throws Exception
{
String num = "-.555555555555555555555555555555";
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
assertEquals(new BigDecimal(num), w.number);
}

// [databind#4435]
@Test
public void testNumberStartingWithPlusDot() throws Exception
{
String num = "+.555555555555555555555555555555";
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
assertEquals(new BigDecimal(num), w.number);
}

private String generateJson(final String fieldName) {
final int len = 1200;
final StringBuilder sb = new StringBuilder();
Expand Down

0 comments on commit 6224569

Please sign in to comment.