File tree 4 files changed +20
-11
lines changed
main/java/com/fasterxml/jackson/databind
test/java/com/fasterxml/jackson/databind/jsontype
4 files changed +20
-11
lines changed Original file line number Diff line number Diff line change @@ -153,15 +153,11 @@ public JavaType constructType(Type type) {
153
153
154
154
/**
155
155
* Convenience method for constructing subtypes, retaining generic
156
- * type parameter (if any)
156
+ * type parameter (if any).
157
+ *<p>
158
+ * Note: since 2.11 handling has varied a bit across serialization, deserialization.
157
159
*/
158
- public JavaType constructSpecializedType (JavaType baseType , Class <?> subclass ) {
159
- // simple optimization to avoid costly introspection if type-erased type does NOT differ
160
- if (baseType .getRawClass () == subclass ) {
161
- return baseType ;
162
- }
163
- return getConfig ().constructSpecializedType (baseType , subclass );
164
- }
160
+ public abstract JavaType constructSpecializedType (JavaType baseType , Class <?> subclass );
165
161
166
162
/**
167
163
* Lookup method called when code needs to resolve class name from input;
Original file line number Diff line number Diff line change @@ -252,6 +252,13 @@ public final TypeFactory getTypeFactory() {
252
252
return _config .getTypeFactory ();
253
253
}
254
254
255
+ @ Override // since 2.11
256
+ public JavaType constructSpecializedType (JavaType baseType , Class <?> subclass ) {
257
+ // No specialized handling for deserialization, but needs to be implemented
258
+ return baseType .hasRawClass (subclass ) ? baseType
259
+ : getConfig ().constructSpecializedType (baseType , subclass );
260
+ }
261
+
255
262
/**
256
263
* Method for accessing default Locale to use: convenience method for
257
264
*<pre>
Original file line number Diff line number Diff line change @@ -313,8 +313,7 @@ public void setNullKeySerializer(JsonSerializer<Object> nks)
313
313
314
314
/*
315
315
/**********************************************************
316
- /* DatabindContext implementation (and closely related
317
- /* but ser-specific)
316
+ /* DatabindContext implementation (and closely related but ser-specific)
318
317
/**********************************************************
319
318
*/
320
319
@@ -334,6 +333,13 @@ public final TypeFactory getTypeFactory() {
334
333
return _config .getTypeFactory ();
335
334
}
336
335
336
+ @ Override // since 2.11
337
+ public JavaType constructSpecializedType (JavaType baseType , Class <?> subclass ) {
338
+ // Need little bit different handling due to [databind#2632]
339
+ return baseType .hasRawClass (subclass ) ? baseType
340
+ : getConfig ().constructSpecializedType (baseType , subclass );
341
+ }
342
+
337
343
@ Override
338
344
public final Class <?> getActiveView () { return _serializationView ; }
339
345
Original file line number Diff line number Diff line change @@ -139,7 +139,7 @@ public void testSpecializeIncompatibleRawType() throws Exception
139
139
assertNotNull (json );
140
140
fail ("Should not (yet?) pass" );
141
141
} catch (JsonMappingException e ) {
142
- verifyException (e , "Failed to specialize base type " );
142
+ verifyException (e , "Failed to specialize base type " );
143
143
}
144
144
}
145
145
}
You can’t perform that action at this time.
0 commit comments