File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed
main/java/com/fasterxml/jackson/databind/util
test/java/com/fasterxml/jackson/databind/interop Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ Project: jackson-databind
44=== Releases ===
55------------------------------------------------------------------------
66
7- 2.18.0 (not yet released)
7+ 2.17.3 (not yet released)
8+
9+ #4718 : Should not fail on trying to serialize `java.time.DateTimeException`
810
9112.17.2 (05 -Jul-2024 )
1012
Original file line number Diff line number Diff line change @@ -304,6 +304,10 @@ public static String checkUnsupportedType(JavaType type) {
304304 if (className .indexOf ('.' , 10 ) >= 0 ) {
305305 return null ;
306306 }
307+ // [databind#4718]: Also don't worry about Exception type(s)
308+ if (type .isTypeOrSubTypeOf (Throwable .class )) {
309+ return null ;
310+ }
307311 typeName = "Java 8 date/time" ;
308312 moduleName = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" ;
309313 } else if (isJodaTimeClass (className )) {
Original file line number Diff line number Diff line change 11package com .fasterxml .jackson .databind .interop ;
22
3+ import java .time .DateTimeException ;
34import java .time .Instant ;
45import java .time .OffsetDateTime ;
56import java .time .ZoneId ;
@@ -84,4 +85,19 @@ public void testAllowAsEmbedded() throws Exception
8485 }
8586 }
8687 }
88+
89+ // [databind#4718]: should not block serialization of `DateTimeException`
90+ @ Test
91+ public void testAllowExceptionSer () throws Exception {
92+ String json = MAPPER .writeValueAsString (new DateTimeException ("Test!" ));
93+ assertTrue (MAPPER .readTree (json ).isObject ());
94+ }
95+
96+ // [databind#4718]: should not block deserialization of `DateTimeException`
97+ @ Test
98+ public void testAllowExceptionDeser () throws Exception {
99+ DateTimeException exc = MAPPER .readValue ("{\" message\" :\" test!\" }" ,
100+ DateTimeException .class );
101+ assertNotNull (exc );
102+ }
87103}
You can’t perform that action at this time.
0 commit comments