Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4435 (or rather, mark as fixed; fix via jackson-core) #4446

Merged
merged 1 commit into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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