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

Add test verifying fix of #4577 (via jackson-core/1308) #4578

Merged
merged 1 commit into from
Jun 13, 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
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ Project: jackson-databind
#4575: StdDelegatingSerializer does not consider a Converter that may
return null for a non-null input
(reported, fix contributed by Peter L)
#4577: Cannot deserialize value of type `java.math.BigDecimal` from
String "3." (not a valid representation)
(reported by @dmelisso)

2.17.1 (04-May-2024)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,24 +106,23 @@ public void testBigIntegerUnlimited() throws Exception
@Test
public void testNumberStartingWithDot() throws Exception {
_testNumberWith(".555555555555555555555555555555");
}

// [databind#4435]
@Test
public void testNumberStartingWithMinusDot() throws Exception {
_testNumberWith("-.555555555555555555555555555555");
_testNumberWith("+.555555555555555555555555555555");
}

// [databind#4435]
// [databind#4577]
@Test
public void testNumberStartingWithPlusDot() throws Exception {
_testNumberWith("+.555555555555555555555555555555");
public void testNumberEndingWithDot() throws Exception {
_testNumberWith("55.");
_testNumberWith("-55.");
_testNumberWith("+55.");
}

private void _testNumberWith(String num) throws Exception
{
BigDecimal exp = new BigDecimal(num);
BigDecimalWrapper w = MAPPER.readValue("{\"number\":\"" + num + "\"}", BigDecimalWrapper.class);
assertEquals(new BigDecimal(num), w.number);
assertEquals(exp, w.number);
}

private String generateJson(final String fieldName) {
Expand Down