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

Deprecated jackson fix #12373

Closed
wants to merge 6 commits into from
Closed

Conversation

jimjoamz
Copy link

Description

Druid uses deprecated Jackson methods getGenericType. This method was deprecated in Jackson 2.7 and is dropped in Jackson 2.11

This PR allows any version of Druid built with Jackson 2.10 to be able to run against more recent versions of Jackson in its classpath

This PR also allows Druid to build against both Jackson 2.10 and Jackson 2.12, setting it up to migrate should any Jackson security issues be exposed in older version.

This PR has:

  • [x ] been self-reviewed.
  • [x ] been tested in a test Druid cluster.

…ethods

* getGenericType is removed completely in Jackson 2.11
* This fix allows Druid to compile with Jackson 2.12+ as well as for existing distributions to replace version 2.10 with 2.12 at runtime.
@@ -58,9 +58,9 @@ public Object findInjectableValueId(AnnotatedMember m)
if (m instanceof AnnotatedMethod) {
throw new IAE("Annotated methods don't work very well yet...");
}
return Key.get(m.getGenericType());
return Key.get(m.getRawType());
Copy link
Member

Choose a reason for hiding this comment

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

    /**
     * JDK declared generic type of the annotated element; definition
     * of what exactly this means depends on sub-class. Note that such type
     * cannot be reliably resolved without {@link TypeResolutionContext}, and
     * as a result use of this method was deprecated in Jackson 2.7: see
     * {@link #getType} for replacement.
     *
     * @deprecated Since 2.7 should instead use {@link #getType()}. To be removed from 2.9
     */

I'm a little confused that the javadoc indicates that getType should be used as a replacement, and current getGenericType calls getRawType() internally.

Copy link
Author

Choose a reason for hiding this comment

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

Hmm good catch. Here's some more confusion for the pile. getType was marked deprecated in 2.10 as well but seems to be un-deprecated in 2.11+

https://github.com/FasterXML/jackson-databind/blob/2.10/src/main/java/com/fasterxml/jackson/databind/introspect/Annotated.java#L47-L49

https://github.com/FasterXML/jackson-databind/blob/2.11/src/main/java/com/fasterxml/jackson/databind/introspect/Annotated.java#L41-L47

I can swap this to getType() instead if that is preferred.

Copy link
Member

Choose a reason for hiding this comment

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

I didn't see that getType was marked deprecated in 2.10 from the link above. Instead public final JavaType getType(TypeBindings bogus) was marked deprecated.

IMO, it's better to follow the javadoc the replace the deprecated API.

Copy link
Author

Choose a reason for hiding this comment

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

Sorry for the delay on getting back to you.

Oof yep I misread. I will update this Pull Request!

Copy link
Author

@jimjoamz jimjoamz Apr 5, 2022

Choose a reason for hiding this comment

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

Seems like the Javadoc recommendation doesn't work the same and getRawType is what we want here.

I'm working on getting tests building locally, I was using JDK17 which I see is a no-no in the build instructions. Sorry for the churn on this. Are you okay with pulling 671c984 as is?

Copy link

This pull request has been marked as stale due to 60 days of inactivity.
It will be closed in 4 weeks if no further activity occurs. If you think
that's incorrect or this pull request should instead be reviewed, please simply
write any comment. Even if closed, you can still revive the PR at any time or
discuss it on the [email protected] list.
Thank you for your contributions.

@github-actions github-actions bot added the stale label Dec 11, 2023
Copy link

github-actions bot commented Jan 9, 2024

This pull request/issue has been closed due to lack of activity. If you think that
is incorrect, or the pull request requires review, you can revive the PR at any time.

@github-actions github-actions bot closed this Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants