Converter Inheritance
See original GitHub issueHi guys,
I think there is a bug emerged in #288 Converter: Bean to AnotherBean. It fires when you want to use the same converter between parent and derived classes by forcing the expected type of deserialization to the base of converter input type (i.e. the parent class), while it looks like it could perfectly be a derived type.
Here is an example:
@JsonDeserialize(converter = ParentEntity.MyConverter.class)
public class ParentEntity {
String a, b;
static class MyConverter<T extends Parent> extends StdConverter<T, T> {
@Override
public T convert(T entity) {
entity.a = entity.a.toLowerCase();
return entity;
}
}
}
@JsonIgnoreProperty({"b"})
public class ChildEntity extends ParentEntity {
public ChildEntity() {
b = "whatever";
}
}
DeserializerCache::_createDeserializer(…) currently creates deserializer with return type of ParentEntity while in code it is expected to be an instance of ChildEntity. This results in java.lang.IllegalStateException: argument type mismatch exception.
The commit introduced this behavior, should the check consider hierarchy as well?
(BTW Jackson version used: 2.9.1, Spring 4.3.22)
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
How to: Convert Flat Inheritance - Documentation - Telerik
The Entity Framework Conversion Wizard allows you to convert Entity Framework models with flat inheritance hierarchies. The purpose of this topic is to ......
Read more >A Closer Look: Rebirth, Conversion, Inheritance - Craig Keener
A convert was no longer the person he or she had been as a gentile, before God, the law, or Israel; his or...
Read more >inheritance of a convert | Rabbi David Sperling | Ask the rabbi
The convert will inherit part of the Land of Israel together with their tribe. Their children are also considered as part of the...
Read more >Proper Inheritance and Substitutability, C++ FAQ - Standard C++
(Note: this FAQ has to do with public inheritance; private and protected ... C++ allows the conversion Derived* → Base* , since a...
Read more >How to make inheritance hierarchy for Type Converter of Dart ...
I resolved this problem in a roundabout way. I use mixin keyword instead of direct inheritance.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have accidently closed the issue, didn’t actually mean to.
@amirtu I think that might work? Sub-class relationship does retain generic typing, so
T
should resolve properly withinconvert
method.