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

[improve][io] Fix Kotlin version issue for functions built in Kotlin #19924

Closed

Conversation

abhilashmandaliya
Copy link
Contributor

@abhilashmandaliya abhilashmandaliya commented Mar 25, 2023

Motivation

I was trying to implement a custom Sink connector using Kotlin. My Kotlin version was 1.8.10 and was using Jackson in my code. I saw a weird reflection-related error in my code. The debugging ended up with a finding that the Pulsar broker was bringing the Kotlin library dependency which was version 1.4.32 and that was getting loaded before my version. Hence my sink was using the older version of a specific class. While looking for Kotlin support in Pulsar code and feedback from the committers in this PR, I realized that Pulsar code is not using the Kotlin library directly but it is a transitive dependency. The latest stable version of the main dependency(okhttp3) bringing Kotlin(1.6.20) as a transitive dependency doesn't use the latest version of Kotlin(1.8.10). Hence, updated okhttp3, okio, and Kotlin separately for the convenience of an existing structure.

Putting the exception that I got here. (Not sure whether that is required):

Caused by: kotlin.reflect.jvm.internal.KotlinReflectionInternalError: Cannot create type for an unsupported classifier: class kotlin.Unit (Kotlin reflection is not available) (class kotlin.jvm.internal.ClassReference)
        at kotlin.reflect.full.KClassifiers.createType(KClassifiers.kt:48) ~[kotlin-reflect-1.8.10.jar:1.8.10-release-430(1.8.10)]
        at kotlin.reflect.full.KClassifiers.createType$default(KClassifiers.kt:42) ~[kotlin-reflect-1.8.10.jar:1.8.10-release-430(1.8.10)]
        at com.fasterxml.jackson.module.kotlin.KotlinAnnotationIntrospector.<clinit>(KotlinAnnotationIntrospector.kt:218) ~[jackson-module-kotlin-2.14.2.jar:2.14.2]
        at com.fasterxml.jackson.module.kotlin.KotlinModule.setupModule(KotlinModule.kt:121) ~[jackson-module-kotlin-2.14.2.jar:2.14.2]
        at com.fasterxml.jackson.databind.ObjectMapper.registerModule(ObjectMapper.java:853) ~[com.fasterxml.jackson.core-jackson-databind-2.13.4.2.jar:2.13.4.2]

Here kotlin.Unit class is loaded from Kotlin 1.4.32 whereas Jackson was compiled with Kotlin 1.5.32.

Modifications

  • Upgraded transitive org.jetbrains.kotlin:kotlin-stdlib library from 1.4.32 to 1.8.10
  • Upgraded transitive okhttp3 version from 4.9.3 to 4.10.0
  • Upgraded transitive okio version from 2.8.0 to 3.0.0

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository: abhilashmandaliya#1

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Mar 25, 2023
@abhilashmandaliya abhilashmandaliya marked this pull request as draft March 25, 2023 06:32
@abhilashmandaliya abhilashmandaliya marked this pull request as ready for review March 25, 2023 10:31
@nodece nodece requested review from tisonkun and lhotari March 25, 2023 17:03
pom.xml Outdated
@@ -1966,8 +1965,6 @@ flexible messaging model and an intuitive client API.</description>
<test.additional.args/>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<pulsar.broker.compiler.release></pulsar.broker.compiler.release>
Copy link
Member

Choose a reason for hiding this comment

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

This should be done intentionally.

Copy link
Member

Choose a reason for hiding this comment

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

@abhilashmandaliya to fix IDE warning, you can collapse the tag instead of removing it.

Anyway, keep one PR for one purpose (upgrade kotlin lib) can help you get a smooth review experience - we don't distract attention.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @nodece and @tisonkun. Have reverted that change.

Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

I don't think it's an isolated version issue. Instead, you should take a look of how Pulsar uses okio and make an upgrade from the direct deps and then propagate to transitive deps.

@tisonkun
Copy link
Member

tisonkun commented Mar 26, 2023

cc @nicoloboschi since you're the last author for editing these versions in #13065.

@abhilashmandaliya
Copy link
Contributor Author

@nodece @tisonkun @lhotari @nicoloboschi
I have made the changes as per the feedback and also updated the PR description.
GitHub UI did some weird things hence there are several reviews and remove status lines.

@abhilashmandaliya abhilashmandaliya changed the title [improve][misc] Updated org.jetbrains.kotlin:kotlin-stdlib version [improve][io] Fix Kotlin version issue for functions built in Kotlin Mar 27, 2023
pom.xml Outdated
<okio.version>2.8.0</okio.version>
<!-- override kotlin-stdlib used by okio in order to address CVE-2020-29582 -->
<kotlin-stdlib.version>1.4.32</kotlin-stdlib.version>
<okio.version>3.0.0</okio.version>
Copy link
Contributor

Choose a reason for hiding this comment

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

we should move to 3.3.0, based on the changelog it's more stable and it upgrades kotlin to 1.8 as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nicoloboschi Latest stable version of okhttp3 4.10.0 uses 3.0.0 version of okio. Is it okay to use 3.3.0 instead?

@abhilashmandaliya
Copy link
Contributor Author

@nicoloboschi PTAL at the updated library version change.

@abhilashmandaliya abhilashmandaliya requested review from nicoloboschi and removed request for tisonkun March 28, 2023 08:37
Copy link
Contributor

@nicoloboschi nicoloboschi left a comment

Choose a reason for hiding this comment

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

LGTM

@tisonkun
Copy link
Member

@abhilashmandaliya license check failed:

com.squareup.okio-okio-jvm-3.0.0.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-1.6.20.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-common-1.5.31.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-jdk7-1.6.10.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-jdk8-1.6.10.jar unaccounted for in LICENSE
com.squareup.okio-okio-3.3.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-1.8.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-common-1.8.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-jdk7-1.8.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-jdk8-1.8.0.jar mentioned in LICENSE, but not bundled

The first lines can be redundant that you should remove. The final lines about kotlin-stdlib, I'm afraid, indicate an issue that we are missing to bundle them?

@abhilashmandaliya
Copy link
Contributor Author

@abhilashmandaliya license check failed:

com.squareup.okio-okio-jvm-3.0.0.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-1.6.20.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-common-1.5.31.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-jdk7-1.6.10.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-jdk8-1.6.10.jar unaccounted for in LICENSE
com.squareup.okio-okio-3.3.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-1.8.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-common-1.8.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-jdk7-1.8.0.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-jdk8-1.8.0.jar mentioned in LICENSE, but not bundled

The first lines can be redundant that you should remove. The final lines about kotlin-stdlib, I'm afraid, indicate an issue that we are missing to bundle them?

@tisonkun With the latest okio library, we don't need to use a different version of Kotlin hence I removed it from the pom.xml. I forgot to remove it from the LICENCE file. I have fixed that. Not sure why okio error is there.

@tisonkun
Copy link
Member

@abhilashmandaliya I get the error report wrong.

com.squareup.okio-okio-jvm-3.0.0.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-1.6.20.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-common-1.5.31.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-jdk7-1.6.10.jar unaccounted for in LICENSE
org.jetbrains.kotlin-kotlin-stdlib-jdk8-1.6.10.jar unaccounted for in LICENSE

These lines mean that you're now (transitive) depending on these libs but they are not listed (mentioned) in the LICENSE file.

You may double check if the version is correct (kotlin 1.5 and 1.6 while we plan to use 1.8? okio-jvm 3.0.0?). The LICENSE updating job I can do you a favor. But we should confirm the final status logically first.

@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label May 18, 2023
Copy link
Member

@tisonkun tisonkun left a comment

Choose a reason for hiding this comment

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

I push a commit to suppress:

org.jetbrains.kotlin-kotlin-stdlib-1.8.20.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-common-1.8.20.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-jdk7-1.8.20.jar mentioned in LICENSE, but not bundled
org.jetbrains.kotlin-kotlin-stdlib-jdk8-1.8.20.jar mentioned in LICENSE, but not bundled
org.jetbrains-annotations-13.0.jar mentioned in LICENSE, but not bundled

But then the changeset seems a bit strange. Comment inline.

Also, you can ping the reviewers when you make progress - pushing new commits doesn't send notification.

</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>${okhttp3.version}</version>
<exclusions>
Copy link
Member

Choose a reason for hiding this comment

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

@abhilashmandaliya if we exclude kotlin dep here, is it possible we are missing bundling several jars so that the function shade jar won't work?

@abhilashmandaliya
Copy link
Contributor Author

Closing the PR as Pulsar 3.0.0 doesn't bring the older Kotlin version. Thanks a lot, @tisonkun for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants