File tree 3 files changed +21
-0
lines changed
main/java/com/fasterxml/jackson/databind/util
test/java/com/fasterxml/jackson/databind/interop
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ Project: jackson-databind
9
9
#4508 : Deserialized JsonAnySetter field in Kotlin data class is null
10
10
(reported by @MaximValeev)
11
11
(fix by Joo-Hyuk K)
12
+ #4718 : Should not fail on trying to serialize `java.time.DateTimeException`
12
13
13
14
2.18.0 (26 -Sep-2024 )
14
15
Original file line number Diff line number Diff line change @@ -304,6 +304,10 @@ public static String checkUnsupportedType(JavaType type) {
304
304
if (className .indexOf ('.' , 10 ) >= 0 ) {
305
305
return null ;
306
306
}
307
+ // [databind#4718]: Also don't worry about Exception type(s)
308
+ if (type .isTypeOrSubTypeOf (Throwable .class )) {
309
+ return null ;
310
+ }
307
311
typeName = "Java 8 date/time" ;
308
312
moduleName = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" ;
309
313
} else if (isJodaTimeClass (className )) {
Original file line number Diff line number Diff line change 1
1
package com .fasterxml .jackson .databind .interop ;
2
2
3
+ import java .time .DateTimeException ;
3
4
import java .time .Instant ;
4
5
import java .time .OffsetDateTime ;
5
6
import java .time .ZoneId ;
@@ -84,4 +85,19 @@ public void testAllowAsEmbedded() throws Exception
84
85
}
85
86
}
86
87
}
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
+ }
87
103
}
You can’t perform that action at this time.
0 commit comments