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

Try builder first, then fallback to deprecated constructor #2072

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Sineaggi
Copy link

What was changed

Tries the new kotlin jackson module builder first, then falls back to the deprecated constructor.

Why?

Newest jackson (2.17.0) broke abi.

Checklist

  1. Closes KotlinObjectMapperFactory is not forwards compatible #2071

  2. How was this tested:
    Tested the code manually against jackson 2.11, 2.14 and 2.17.

  3. Any docs updates needed?

@Sineaggi Sineaggi requested a review from a team as a code owner May 20, 2024 19:38
@CLAassistant
Copy link

CLAassistant commented May 20, 2024

CLA assistant check
All committers have signed the CLA.

@Sineaggi
Copy link
Author

Sineaggi commented May 20, 2024

The upstream issue has a fix here FasterXML/jackson-module-kotlin#799 but using the builder would have avoided this issue.

val km = KotlinModule()
val km = try {
KotlinModule.Builder()
.build()
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we confirmed this works with jackson v2.9.0?

Copy link
Author

Choose a reason for hiding this comment

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

The existing code doesn't work with jackson 2.9.0

Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure I understand, the Java SDK currently does build and all test pass with jackson 2.9.0

Copy link
Author

@Sineaggi Sineaggi May 22, 2024

Choose a reason for hiding this comment

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

It currently builds with jackson 2.14.2

jacksonVersion = '2.14.2' // [2.9.0,)

Copy link
Author

Choose a reason for hiding this comment

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

It fails with jackson 2.9.0

'void com.fasterxml.jackson.module.kotlin.KotlinModule.<init>(int, boolean, boolean, boolean, com.fasterxml.jackson.module.kotlin.SingletonSupport, boolean, int, kotlin.jvm.internal.DefaultConstructorMarker)'
java.lang.NoSuchMethodError: 'void com.fasterxml.jackson.module.kotlin.KotlinModule.<init>(int, boolean, boolean, boolean, com.fasterxml.jackson.module.kotlin.SingletonSupport, boolean, int, kotlin.jvm.internal.DefaultConstructorMarker)'

Copy link
Contributor

@Quinn-With-Two-Ns Quinn-With-Two-Ns May 23, 2024

Choose a reason for hiding this comment

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

Note the comment

// [2.9.0,) 

indicating our support for 2.9.0

Copy link
Author

@Sineaggi Sineaggi May 23, 2024

Choose a reason for hiding this comment

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

Unless I'm doing something wrong, the code as-is won't work with jackson 2.9.0 master...Sineaggi:sdk-java:jackson-version-test
If you run ./gradlew :temporal-kotlin:test, it should fail with the stacktrace above.

Copy link
Contributor

Choose a reason for hiding this comment

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

If we need to drop support to maintain forward compatibility I would 100% be in favor, but if we can support older versions without harming forward compatibility that would be the best for all SDK users.

Copy link
Author

Choose a reason for hiding this comment

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

I've gone the registerKotlinModule route, which should allow for maximum backwards and forwards compatibility.

@Sineaggi Sineaggi force-pushed the fix-temporal-forwards-compat branch from 6f6cfd9 to 897788e Compare May 22, 2024 02:44
@Sineaggi
Copy link
Author

There is another way to simplify this further, and that is to call the registerKotlinModule function instead of trying to register a KotlinModule ourselves.

@Quinn-With-Two-Ns
Copy link
Contributor

Ah CI is failing because your branch does not have tags , which our CI unfortunately makes use of to detect the version of the SDK, you can use git fetch --tags and then you can push you branch with tags. Sorry for the inconvenience.

@Sineaggi
Copy link
Author

Ah CI is failing because your branch does not have tags

Right, that happened during local testing as well. I've pushed tags now.


testing {
suites {
jacksonVersions.forEach { jacksonVersion ->
Copy link
Contributor

Choose a reason for hiding this comment

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

These tests are not needed since we already have a setup to test multiple versions of dependencies

Copy link
Author

Choose a reason for hiding this comment

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

How are these tests compiled/run? As it stands, it is impossible to call KotlinObjectMapperFactory.new() in a project that forcefully downgrades to jackson 2.9.0. This test shows that that is now possible.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hm yes looking at more carefully your test is doing something slightly different, we test building and running with different version of our dependencies, but here your testing building with one version, but running with another. Finding some breaking ABI change between versions most likely.

Copy link
Contributor

Choose a reason for hiding this comment

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

This test, or the inclusion of org.gradle.api.plugins.jvm.JvmTestSuite appears to be causing some issues with our feature test I haven't had a chance to deep dive as to why. I am fine merging this without this test for now and I'll open an issue to create more thorough testing strategy for breaking catching breaking ABI changes. We should probably do tests like this for more then just jackson versions

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.

KotlinObjectMapperFactory is not forwards compatible
3 participants