-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
2.17Issues planned at earliest for 2.17Issues planned at earliest for 2.17polymorphic-deductionIssues related to "Id.DEDUCTION" mode of `@JsonTypeInfo`Issues related to "Id.DEDUCTION" mode of `@JsonTypeInfo`
Milestone
Description
Search before asking
- I searched in the issues and found nothing similar.
Describe the bug
I'm trying use @JsonAlias
on a class which is a member of a type hierarchy, and then expecting Jackson Databind to be able to use the alias to determine the type.
My class hierarchy is Deduction, annotated with its two concrete implementations:
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCTION)
@JsonSubTypes({
@JsonSubTypes.Type(value = DeductionBean1.class),
@JsonSubTypes.Type(value = DeductionBean2.class)
})
where DeductionBean2
uses an alias.
record DeductionBean2(@JsonAlias("Y") int y) implements Deduction {
}
This fails like so when deserializing {'Y': 2 }
com.fasterxml.jackson.databind.exc.InvalidTypeIdException: Could not resolve subtype of [simple type, class com.fasterxml.jackson.databind.deser.PropertyAliasTest$Deduction]: Cannot deduce unique subtype of `com.fasterxml.jackson.databind.deser.PropertyAliasTest$Deduction` (2 candidates match)
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 9]
Version Information
2.17
master
Reproduction
I've added a test tools.jackson.databind.deser.PropertyAliasTest#testAliasWithPolymorphicDeduction that demonstrates the issue I face.
Expected behavior
Aliases to be respected by DEDUCTION
.
Additional context
No response
Metadata
Metadata
Assignees
Labels
2.17Issues planned at earliest for 2.17Issues planned at earliest for 2.17polymorphic-deductionIssues related to "Id.DEDUCTION" mode of `@JsonTypeInfo`Issues related to "Id.DEDUCTION" mode of `@JsonTypeInfo`