Skip to content

Commit 323cd0b

Browse files
committed
Fix #2064
1 parent 940ebf4 commit 323cd0b

File tree

5 files changed

+21
-6
lines changed

5 files changed

+21
-6
lines changed

release-notes/CREDITS-2.x

+6-2
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,13 @@ Reinhard Prechtl (dnno@github)
800800
Chetan Narsude (243826@github)
801801
* Reported #2038: JDK Serializing and using Deserialized `ObjectMapper` loses linkage
802802
back from `JsonParser.getCodec()`
803-
(2.9.6)
803+
(2.9.6)
804804
805805
Petar Tahchiev (ptahchiev@github)
806806
* Reported #2060: `UnwrappingBeanPropertyWriter` incorrectly assumes the found
807807
serializer is of type `UnwrappingBeanSerializer`
808-
(2.9.6)
808+
(2.9.6)
809+
810+
Brandon Krieger (bkrieger@github)
811+
* Reported #2064: Cannot set custom format for `SqlDateSerializer` globally
812+
(2.9.7)

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Project: jackson-databind
99
#2060: `UnwrappingBeanPropertyWriter` incorrectly assumes the found serializer is
1010
of type `UnwrappingBeanSerializer`
1111
(reported by Petar T)
12+
#2064: Cannot set custom format for `SqlDateSerializer` globally
13+
(reported by Brandon K)
1214
#2079: NPE when visiting StaticListSerializerBase
1315
(reported by WorldSEnder@github)
1416
#2082: `FactoryBasedEnumDeserializer` should be cachable

src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ protected DateTimeSerializerBase(Class<T> type,
6262
public JsonSerializer<?> createContextual(SerializerProvider serializers,
6363
BeanProperty property) throws JsonMappingException
6464
{
65-
if (property == null) {
66-
return this;
67-
}
65+
// Note! Should not skip if `property` null since that'd skip check
66+
// for config overrides, in case of root value
6867
JsonFormat.Value format = findFormatOverrides(serializers, property, handledType());
6968
if (format == null) {
7069
return this;

src/test/java/com/fasterxml/jackson/databind/ser/jdk/SqlDateSerializationTest.java

+10
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,14 @@ public void testPatternWithSqlDate() throws Exception
9494
assertEquals(aposToQuotes("{'dateOfBirth':'1980.04.14'}"),
9595
mapper.writeValueAsString(i));
9696
}
97+
98+
// [databind#2064]
99+
public void testSqlDateConfigOverride() throws Exception
100+
{
101+
ObjectMapper mapper = newObjectMapper();
102+
mapper.configOverride(java.sql.Date.class)
103+
.setFormat(JsonFormat.Value.forPattern("yyyy+MM+dd"));
104+
assertEquals("\"1980+04+14\"",
105+
mapper.writeValueAsString(java.sql.Date.valueOf("1980-04-14")));
106+
}
97107
}

src/test/java/com/fasterxml/jackson/failing/NodeContext2049Test.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx
134134
private ObjectMapper objectMapper;
135135
{
136136
objectMapper = new ObjectMapper();
137-
objectMapper.registerModule(new Module() {
137+
objectMapper.registerModule(new com.fasterxml.jackson.databind.Module() {
138138
@Override
139139
public String getModuleName() {
140140
return "parentSetting";

0 commit comments

Comments
 (0)