Skip to content

Commit

Permalink
Merge branch '2.18' into 2.19
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 29, 2024
2 parents dcb98cb + b9ada30 commit b1e8447
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project: jackson-databind
#4508: Deserialized JsonAnySetter field in Kotlin data class is null
(reported by @MaximValeev)
(fix by Joo-Hyuk K)
#4718: Should not fail on trying to serialize `java.time.DateTimeException`

2.18.0 (26-Sep-2024)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,10 @@ public static String checkUnsupportedType(JavaType type) {
if (className.indexOf('.', 10) >= 0) {
return null;
}
// [databind#4718]: Also don't worry about Exception type(s)
if (type.isTypeOrSubTypeOf(Throwable.class)) {
return null;
}
typeName = "Java 8 date/time";
moduleName = "com.fasterxml.jackson.datatype:jackson-datatype-jsr310";
} else if (isJodaTimeClass(className)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fasterxml.jackson.databind.interop;

import java.time.DateTimeException;
import java.time.Instant;
import java.time.OffsetDateTime;
import java.time.ZoneId;
Expand Down Expand Up @@ -84,4 +85,19 @@ public void testAllowAsEmbedded() throws Exception
}
}
}

// [databind#4718]: should not block serialization of `DateTimeException`
@Test
public void testAllowExceptionSer() throws Exception {
String json = MAPPER.writeValueAsString(new DateTimeException("Test!"));
assertTrue(MAPPER.readTree(json).isObject());
}

// [databind#4718]: should not block deserialization of `DateTimeException`
@Test
public void testAllowExceptionDeser() throws Exception {
DateTimeException exc = MAPPER.readValue("{\"message\":\"test!\"}",
DateTimeException.class);
assertNotNull(exc);
}
}

0 comments on commit b1e8447

Please sign in to comment.