@@ -93,7 +93,7 @@ public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ct
93
93
throws JsonMappingException
94
94
{
95
95
final DeserializationConfig config = ctxt .getConfig ();
96
- // We may also have custom overrides:
96
+ // First: we may also have custom overrides:
97
97
JsonDeserializer <?> deser = _findCustomBeanDeserializer (type , config , beanDesc );
98
98
if (deser != null ) {
99
99
// [databind#2392]
@@ -104,10 +104,8 @@ public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ct
104
104
}
105
105
return (JsonDeserializer <Object >) deser ;
106
106
}
107
- /* One more thing to check: do we have an exception type
108
- * (Throwable or its sub-classes)? If so, need slightly
109
- * different handling.
110
- */
107
+ // One more thing to check: do we have an exception type (Throwable or its
108
+ // sub-classes)? If so, need slightly different handling.
111
109
if (type .isThrowable ()) {
112
110
return buildThrowableDeserializer (ctxt , type , beanDesc );
113
111
}
@@ -139,6 +137,14 @@ public JsonDeserializer<Object> createBeanDeserializer(DeserializationContext ct
139
137
}
140
138
// For checks like [databind#1599]
141
139
_validateSubType (ctxt , type , beanDesc );
140
+
141
+ // 05-May-2020, tatu: [databind#2683] Let's actually pre-emptively catch
142
+ // certain types (for now, java.time.*) to give better error messages
143
+ deser = _findUnsupportedTypeDeserializer (ctxt , type , beanDesc );
144
+ if (deser != null ) {
145
+ return (JsonDeserializer <Object >)deser ;
146
+ }
147
+
142
148
// Use generic bean introspection to build deserializer
143
149
return buildBeanDeserializer (ctxt , type , beanDesc );
144
150
}
@@ -181,7 +187,30 @@ protected JsonDeserializer<?> findStdDeserializer(DeserializationContext ctxt,
181
187
}
182
188
return deser ;
183
189
}
184
-
190
+
191
+ /**
192
+ * Helper method called to see if given type, otherwise to be taken as POJO type,
193
+ * is "known but not supported" JDK type, and if so, return alternate handler
194
+ * (deserializer).
195
+ * Initially added to support more meaningful error messages when "Java 8 date/time"
196
+ * support module not registered.
197
+ *
198
+ * @since 2.12
199
+ */
200
+ protected JsonDeserializer <Object > _findUnsupportedTypeDeserializer (DeserializationContext ctxt ,
201
+ JavaType type , BeanDescription beanDesc )
202
+ throws JsonMappingException
203
+ {
204
+ if (ClassUtil .isJava8TimeClass (type .getRawClass ())) {
205
+ // 05-May-2020, tatu: Should we check for possible Shape override to "POJO"?
206
+ // (to let users force 'serialize-as-POJO'?
207
+ return new UnsupportedTypeDeserializer (type ,
208
+ "Java 8 date/time type " +ClassUtil .getTypeDescription (type )
209
+ +" not supported by default: please register module `jackson-datatype-jsr310` to add handling" );
210
+ }
211
+ return null ;
212
+ }
213
+
185
214
protected JavaType materializeAbstractType (DeserializationContext ctxt ,
186
215
JavaType type , BeanDescription beanDesc )
187
216
throws JsonMappingException
@@ -434,8 +463,7 @@ public JsonDeserializer<Object> buildThrowableDeserializer(DeserializationContex
434
463
435
464
/*
436
465
/**********************************************************
437
- /* Helper methods for Bean deserializer construction,
438
- /* overridable by sub-classes
466
+ /* Helper methods for Bean deserializer construction
439
467
/**********************************************************
440
468
*/
441
469
0 commit comments