Skip to content

Commit

Permalink
Mark #4694 as fixed (actual fix via jackson-core) (#4700)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 13, 2024
1 parent b9d5e42 commit 7c336bf
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 40 deletions.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Project: jackson-databind
(reported by Mathijs V)
#4688: Should allow deserializing with no-arg `@JsonCreator(mode = DELEGATING)`
(contributed by Carter K)
#4694: Deserializing `BigDecimal` with large number of decimals result in incorrect value
(reported by @lnthai2002)
2.17.2 (05-Jul-2024)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,30 @@ public void testBigDecimalUnwrapped() throws Exception
NestedBigDecimalHolder2784 result = mapper.readValue(JSON, NestedBigDecimalHolder2784.class);
assertEquals(new BigDecimal("5.00"), result.holder.value);
}

private final String BIG_DEC_STR;
{
StringBuilder sb = new StringBuilder("-1234.");
// Above 500 chars we get a problem:
for (int i = 520; --i >= 0; ) {
sb.append('0');
}
BIG_DEC_STR = sb.toString();
}
private final BigDecimal BIG_DEC = new BigDecimal(BIG_DEC_STR);

// [databind#4694]: decoded wrong by jackson-core/FDP for over 500 char numbers
@Test
public void bigDecimal4694FromString() throws Exception
{
assertEquals(BIG_DEC, MAPPER.readValue(BIG_DEC_STR, BigDecimal.class));
}

@Test
public void bigDecimal4694FromBytes() throws Exception
{
byte[] b = utf8Bytes(BIG_DEC_STR);
assertEquals(BIG_DEC, MAPPER.readValue(b, 0, b.length, BigDecimal.class));
}

}

This file was deleted.

0 comments on commit 7c336bf

Please sign in to comment.