From 310734f7dc024149db497e3050c25b62036b1635 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 28 Sep 2024 21:44:03 -0700 Subject: [PATCH] Fix #319: add test to show databind 2.18.1 fixes issue (#321) --- .../jsr310/misc/DateTimeExceptionTest.java | 24 +++++++++++++++++++ release-notes/CREDITS-2.x | 4 ++++ release-notes/VERSION-2.x | 5 ++++ 3 files changed, 33 insertions(+) create mode 100644 datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java diff --git a/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java new file mode 100644 index 00000000..e9eb3bc5 --- /dev/null +++ b/datetime/src/test/java/com/fasterxml/jackson/datatype/jsr310/misc/DateTimeExceptionTest.java @@ -0,0 +1,24 @@ +package com.fasterxml.jackson.datatype.jsr310.misc; + +import java.time.DateTimeException; + +import org.junit.Test; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.datatype.jsr310.ModuleTestBase; + +import static org.junit.Assert.assertEquals; + +public class DateTimeExceptionTest extends ModuleTestBase +{ + private final ObjectMapper MAPPER = newMapper(); + + // [modules-java#319]: should not fail to ser/deser DateTimeException + @Test + public void testDateTimeExceptionRoundtrip() throws Exception + { + String json = MAPPER.writeValueAsString(new DateTimeException("Test!")); + DateTimeException result = MAPPER.readValue(json, DateTimeException.class); + assertEquals("Test!", result.getMessage()); + } +} diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index 5f851e0e..54f33789 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -199,3 +199,7 @@ Emanuel Trandafir (@etrandafir93) * Contribtued fix for #274: Deserializing `java.time.Month` from an int causes an off-by-one error (`0`->`Jan`,`11`->`Dec`), because it's an enum (2.17.0) + +Ólafur Bragason (@olibraga) + * Reported #319: `java.time.DateTimeException` serialization fails + (2.18.1) diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index 0b590a63..527e8754 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -8,6 +8,11 @@ Modules: === Releases === ------------------------------------------------------------------------ +2.18.1 (not yet released) + +#319: `java.time.DateTimeException` serialization fails + (repored by Ólafur B) + 2.18.0 (26-Sep-2024) No changes since 2.17