Skip to content

Conversation

@alexanderkjall
Copy link

Description

A new version of jackson-databind have been released, and if another dependency pulls that into a project together with this project that causes a runtime failure as seen below:

Caused by: java.lang.NoSuchFieldError: READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE
        at com.fasterxml.jackson.databind.deser.std.EnumDeserializer.createContextual(EnumDeserializer.java:211)
        at com.fasterxml.jackson.databind.DeserializationContext.handlePrimaryContextualization(DeserializationContext.java:836)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:550)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:294)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
        at com.fasterxml.jackson.databind.DeserializationContext.findNonContextualValueDeserializer(DeserializationContext.java:644)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:539)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:294)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
        at com.fasterxml.jackson.databind.DeserializationContext.findNonContextualValueDeserializer(DeserializationContext.java:644)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:539)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:294)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
        at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:621)
        at com.fasterxml.jackson.databind.deser.std.MapDeserializer.createContextual(MapDeserializer.java:328)
        at com.fasterxml.jackson.databind.DeserializationContext.handlePrimaryContextualization(DeserializationContext.java:836)
        at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.resolve(BeanDeserializerBase.java:550)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:294)
        at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244)
        at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142)
        at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:621)
        at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.createContextual(ObjectArrayDeserializer.java:147)
        at com.fasterxml.jackson.databind.DeserializationContext.handleSecondaryContextualization(DeserializationContext.java:867)
        at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:659)
        at com.fasterxml.jackson.databind.ObjectReader._prefetchRootDeserializer(ObjectReader.java:2430)
        at com.fasterxml.jackson.databind.ObjectReader.forType(ObjectReader.java:771)
        at com.fasterxml.jackson.databind.ObjectReader.forType(ObjectReader.java:791)
        at org.kohsuke.github.GitHubResponse.parseBody(GitHubResponse.java:104)
        at org.kohsuke.github.GitHubPageIterator.lambda$fetch$0(GitHubPageIterator.java:147)
        at org.kohsuke.github.GitHubClient.createResponse(GitHubClient.java:549)
        at org.kohsuke.github.GitHubClient.sendRequest(GitHubClient.java:436)
        at org.kohsuke.github.GitHubPageIterator.fetch(GitHubPageIterator.java:146)
        at org.kohsuke.github.GitHubPageIterator.hasNext(GitHubPageIterator.java:93)
        at org.kohsuke.github.PagedIterator.fetch(PagedIterator.java:116)
        at org.kohsuke.github.PagedIterator.hasNext(PagedIterator.java:84)
        at org.kohsuke.github.GHPerson.getRepositories(GHPerson.java:76)

Upgrading jackson-databind here seems to be a non-problematic upgrade, so this is maybe the easiest path forward for compatibility.

I opted for the latest minor version of 2.15, but I don't think that is important for the above error.

Before submitting a PR:

  • Changes must not break binary backwards compatibility. If you are unclear on how to make the change you think is needed while maintaining backward compatibility, CONTRIBUTING.md for details.
  • Add JavaDocs and other comments as appropriate. Consider including links in comments to relevant documentation on https://docs.github.com/en/rest .
  • Add tests that cover any added or changed code. This generally requires capturing snapshot test data. See CONTRIBUTING.md for details.
  • Run mvn -D enable-ci clean install site locally. If this command doesn't succeed, your change will not pass CI.
  • Push your changes to a branch other than main. You will create your PR from that branch.

When creating a PR:

  • Fill in the "Description" above with clear summary of the changes. This includes:
    • If this PR fixes one or more issues, include "Fixes #" lines for each issue.
    • Provide links to relevant documentation on https://docs.github.com/en/rest where possible.
  • All lines of new code should be covered by tests as reported by code coverage. Any lines that are not covered must have PR comments explaining why they cannot be covered. For example, "Reaching this particular exception is hard and is not a particular common scenario."
  • Enable "Allow edits from maintainers".

@codecov
Copy link

codecov bot commented May 31, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (afb0ae7) 79.93% compared to head (c56f5e1) 79.93%.

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #1663   +/-   ##
=========================================
  Coverage     79.93%   79.93%           
  Complexity     2208     2208           
=========================================
  Files           212      212           
  Lines          6687     6687           
  Branches        364      364           
=========================================
  Hits           5345     5345           
  Misses         1128     1128           
  Partials        214      214           

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@bitwiseman
Copy link
Member

@alexanderkjall
Thanks for the PR.
This is very strange - The enum in question still exists in 2.15.x and should continue to work.
https://javadoc.io/doc/com.fasterxml.jackson.core/jackson-databind/latest/com/fasterxml/jackson/databind/DeserializationFeature.html#READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE

I'm particularly concerned the updating to using 2.15 in the build will break compatibility with 2.14 and earlier.

@alexanderkjall
Copy link
Author

I agree that that error is strange, since it's two dependency layers down from our application I thought that the best way to debug it would be to bump the dependency version in github-api, see what breaks and then fix it, but nothing did brake.

I'm not 100% sure on how to ensure compatibility here, or even determine if there is a real compatibility problem or if it was gradle that somehow got tricked into pulling in an incompatible set of dependencies.

I guess there is two cases:

  1. There is no real compatibility problem - 2.15 can be merged without problem.
  2. There is a problem - Then at some point other projects will start using 2.15, and users of github-api would either be blocked from using those versions, or github-api upgrades and the users would be blocket from using the old version of those other dependencies.

I'm not at all sure on how to resolve if there is a real problem, and if it is how to determine a good point in time to upgrade.

@bitwiseman
Copy link
Member

@alexanderkjall
I'm not sure how it is happening, but it sounds like some kind of binary incompatibility.

I'm guessing there's dependency mismatch issue.

Please try using https://github.com/FasterXML/jackson-bom to synchronize the versions of all Jackson binaries in your project. Add the following dependency import to your project's pom.xml dependencyManagement section:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.fasterxml.jackson</groupId>
      <artifactId>jackson-bom</artifactId>
      <version>2.15.2</version>
      <scope>import</scope>
      <type>pom</type>
    </dependency>   
  </dependencies>
</dependencyManagement>

Then use the published version of github-api that would usually depend on 2.14.0.

Assuming that everything works, then we can safely take this PR - there's no underly binary incompatibility that would break other projects.

@alexanderkjall
Copy link
Author

Thanks for the suggestion to use the bom, that did indeed fix the problem in our codebase.

@bitwiseman
Copy link
Member

Okay that means this is change is likely safe to accept.

@bitwiseman bitwiseman merged commit 6f8c299 into hub4j:main Jun 2, 2023
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.

2 participants