From 19feb3850bb815308af7a7c111c9b81f803d52ad Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Thu, 13 Jun 2024 16:20:40 -0700 Subject: [PATCH] Add test verifying fix of #4577 (via jackson-core/1308) --- release-notes/VERSION-2.x | 3 +++ .../deser/jdk/BigNumbersDeserTest.java | 19 +++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 2781e8b000..3b148900ab 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -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) diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigNumbersDeserTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigNumbersDeserTest.java index d65f52eb1d..43cfb7cae3 100644 --- a/src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigNumbersDeserTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/deser/jdk/BigNumbersDeserTest.java @@ -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) {