Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow introspection and polymorphic type handling to use JsonTypeInfo.Value #3942

Closed

Conversation

JooHyukKim
Copy link
Member

@JooHyukKim JooHyukKim commented May 19, 2023

part of #3943

@JooHyukKim
Copy link
Member Author

Should we deprecate below methods in 2.16? --they will be gone in 3.0.

  • Deprecate TypeResolverBuilder.init(JsonTypeInfo.Id, TypeIdResolver)?
  • Deprecate configuration methods of TypeResolverBuilder? List goes inclusion(As), typeProperty(String), defaultImpl(Class<?>), typeIdVisibility(boolean)?

@JooHyukKim JooHyukKim marked this pull request as ready for review May 20, 2023 15:34
@JooHyukKim JooHyukKim marked this pull request as draft May 20, 2023 15:35
@JooHyukKim
Copy link
Member Author

JooHyukKim commented May 20, 2023

@cowtowncoder may I ask for a brief review? Just to make sure we are heading to the right direction.😄 If I were to take this version further, I will probably just add some test cases.

Thank you so much in advance 🙏🏼🙏🏼

@JooHyukKim JooHyukKim changed the title Allow introspection and config-override system to use JsonTypeInfo.Value. Allow introspection and polymorphic type handling to use JsonTypeInfo.Value May 20, 2023
@JooHyukKim JooHyukKim marked this pull request as ready for review May 21, 2023 08:31
@@ -1498,27 +1509,30 @@ protected PropertyName _findConstructorName(Annotated a)
protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config,
Annotated ann, JavaType baseType)
{
// since 2.16 : backporting {@link JsonTypeInfo.Value} from 3.0
final AnnotationIntrospector ai = config.getAnnotationIntrospector();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are in AnnotationIntrospector, should not look for config here (in fact that'd be wrong with AI pair, I think)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Changed to plan findPolymorphicTypeInfo(config, ann); 👍🏻

*
* @since 2.16
*/
public T init(JsonTypeInfo.Value settings, TypeIdResolver res);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would require default implementation, I think, to avoid breakage wrt backwards-compatibility (existing implementations can't really implement it). Not sure if that impl should do nothing or throw an exception...

@@ -256,6 +256,28 @@ public void testUnWrappedMapWithDefaultType() throws Exception{
assertEquals("{\"@type\":\"HashMap\",\"xxxB\":\"bar\"}", json);
}

// [databind#838]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not the right issue? But also, does this belong here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, should not have copied the issue label 😅.

I was struggling to figure out (I am still 🥲) what should be tested and wrote a sample replacing the old behavior.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. No problem, was just confused :)

@cowtowncoder
Copy link
Member

cowtowncoder commented May 22, 2023

Ok, how about we split this further? At first only add new method in AnnotationIntrospector (and AnnotationIntrospectorPair). I could merge that quickly since that is safe & would make trickier changes easier to review.

And then the meaningful changes can follow. I think XML module (jackson-dataformat-xml) is one place where matching changes are needed.

@JooHyukKim
Copy link
Member Author

Ok, how about we split this further? At first only add new method in AnnotationIntrospector (and AnnotationIntrospectorPair). I could merge that quickly since that is safe & would make trickier changes easier to review.

Sounds like a plan👍🏻. I will turn this PR into draft, create a new one with only AnnotationIntrospector (and AnnotationIntrospectorPair part, and document the new PR in #3943.

Thank you for your suggestion @cowtowncoder 🙏🏼🙏🏼

@JooHyukKim JooHyukKim marked this pull request as draft May 22, 2023 03:22
@JooHyukKim JooHyukKim force-pushed the Introduce-JsonTypeInfo.Value branch from 7f116b5 to 57b740e Compare May 22, 2023 22:47
/**
* @since 2.16 (backported from Jackson 3.0)
*/
protected Boolean _requireTypeIdForSubtypes;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this field should be included in this PR, but #3891

cowtowncoder and others added 25 commits May 22, 2023 20:02
….com/JooHyukKim/jackson-databind into Introduce-JsonTypeInfo.Value"

This reverts commit 93983d3, reversing
changes made to c30d8a6.
….com/JooHyukKim/jackson-databind into Introduce-JsonTypeInfo.Value"

This reverts commit 93983d3, reversing
changes made to c30d8a6.
@JooHyukKim
Copy link
Member Author

CLOSED

Will close this PR and open #3953 due to severe Git conflicts.

@JooHyukKim JooHyukKim closed this May 23, 2023
@JooHyukKim JooHyukKim deleted the Introduce-JsonTypeInfo.Value branch July 14, 2023 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants