question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Converter Inheritance

See original GitHub issue

Hi 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:closed
  • Created 4 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
amirtucommented, Jan 19, 2020

I have accidently closed the issue, didn’t actually mean to.

0reactions
cowtowncodercommented, Jan 29, 2020

@amirtu I think that might work? Sub-class relationship does retain generic typing, so T should resolve properly within convert method.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found