File tree 3 files changed +23
-1
lines changed
main/java/com/fasterxml/jackson/databind/util
test/java/com/fasterxml/jackson/databind/interop
3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ Project: jackson-databind
4
4
=== Releases ===
5
5
------------------------------------------------------------------------
6
6
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`
8
10
9
11
2.17.2 (05 -Jul-2024 )
10
12
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