Skip to content

Upgrade Jackson from 2.9.10 to 2.16.2 #1

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

Closed
wants to merge 4 commits into from
Closed

Conversation

mertant
Copy link
Owner

@mertant mertant commented Nov 11, 2024

Why?

Issue:

As described in the linked issue, if another dependency has Jackson as a transitive dependency and causes it to be updated to >2.15 in a project, then the Intercom HttpClient.readEntity method breaks (it begins to throw Jackson Databind UnrecognizedPropertyExceptions at runtime).

This PR attempts to upgrade the Jackson dependency of intercom-java & then fix the ObjectMapper as necessary.

See also:

How?

  1. Update Jackson from 2.9 to 2.15
    • Run tests, confirm they still pass.
  2. Then update Jackson to 2.16
    • Run tests, confirm that they now begin to fail with: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "type" (class io.intercom.api.TypedData), not marked as ignorable (0 known properties: ])
  3. Fix usage of Jackson ObjectMapper:
  • Try to add the necessary ObjectMapper configurations to MapperSupportso that it will (once again, as in older versions of Jackson) ignore any uncrecognized properties.
    • Set FAIL_ON_UNKNOWN_PROPERTIES to false
    • => This makes some of the tests pass; however, other tests still fail with com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class io.intercom.api.TypedData and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS) (through reference chain: io.intercom.api.User["companies"]
    • => Set FAIL_ON_EMPTY_BEANS to false
    • However, other tests till fail with e.g. java.lang.ClassCastException: io.intercom.api.TypedData cannot be cast to io.intercom.api.Segment.

It seems that something breaks the serialization of nested fields that are collections, such as tags and segments:

  "segments" : {
    "segments" : [ { } ],
    "type" : "segment.list"
  },
  "tags" : {
    "tags" : [ { } ],
    "type" : "tag.list"
  }

should be:

  "segments": {
    "type": "segment.list",
    "segments": [
      {
        "id": "5310d8e7598c9a0b24000002"
      }
    ]
  },
  "tags": {
    "type": "tag.list",
    "tags": [
      {
        "id": "202"
      }
    ]
  }

@mertant mertant force-pushed the upgrade-jackson-2.16 branch from 4dd8a69 to 253340f Compare November 11, 2024 09:11
@mertant mertant changed the title Upgrade Jackson from 2.9.10 to 2.15.4 Upgrade Jackson from 2.9.10 to 2.16.2 Nov 11, 2024
(test begin to fail with `Unrecognized field "type" (class io.intercom.api.TypedData), not marked as ignorable (0 known properties: ])`)
@mertant mertant force-pushed the upgrade-jackson-2.16 branch from 7b75d33 to 790084b Compare November 11, 2024 09:13
@mertant
Copy link
Owner Author

mertant commented Dec 13, 2024

According to this, Intercom Java SDK will not be updated

intercom#311 (comment)

For the Java SDK, there are no planned updates at this time due to it being in maintenance mode as I said. So our recommendation is that you use regular API endpoints as opposed to the SDK wrapper.

@mertant
Copy link
Owner Author

mertant commented May 12, 2025

Despite the above information, there now seems to be an upgrade to the official repository which upgrades jackson-databind to 2.17.2:

https://github.com/intercom/intercom-java/pull/321/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7R16

Therefore, I'm closing this PR.

@mertant mertant closed this May 12, 2025
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.

1 participant