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

[fix] Remove pulsar-broker-common dependency from pulsar-client #17855

Merged
merged 10 commits into from
Sep 30, 2022

Conversation

nicoloboschi
Copy link
Contributor

@nicoloboschi nicoloboschi commented Sep 27, 2022

Motivation

#17198 added the pulsar-broker-common dependency to the pulsar-client module. This is very bad because in this way user applications will download the pulsar broker internals dependency and they may start using unsupported API.
Also this breaks the JDK 8 compatibility for the client. This looks like is no more covered by the CI and I will address it in another pull.

Modifications

  • Moved BaseGenerateDocumentation to the pulsar-common module
  • Moved source code compatibility to JDK8
  • Replaced FieldContext usage with reflections because it's no more accessible
  • Set the release flag to 8 for the packages-core module
  • Added the enforcer to the pulsar-client-all module to verify binary compatibility to jdk8
  • doc-not-needed

Fork test runs: nicoloboschi#17

@nicoloboschi nicoloboschi requested review from urfreespace and 315157973 and removed request for urfreespace September 27, 2022 12:21
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Sep 27, 2022
Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

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

LGTM. Could you open a match PR in your fork to verify it?

@lhotari
Copy link
Member

lhotari commented Sep 27, 2022

I'd suggest applying https://www.mojohaus.org/extra-enforcer-rules/enforceBytecodeVersion.html to prevent future regressions. The Pulsar client modules must be JDK 8 only. This applies to pulsar-common too.

@nicoloboschi
Copy link
Contributor Author

nicoloboschi commented Sep 28, 2022

@lhotari I added the enforcer, it was a great suggestion.

Thanks to it, I found out that also pulsar-package-core is included in pulsar-admin-client dependency, since 2020. (I guess Pulsar 2.6). So we cannot remove the package without a breaking change. We could eventually move used classes to the pulsar-client-admin-api module. If a user inadvertly imported some internal classes from pulsar-package-core, they will get errors during the client upgrade. However I think it's fine to change it starting from 2.12.0

Since Pulsar 2.11 will be released using the maven release flag to 17, we absolutely need to apply my latest commit 82beb7b to branch-2.11 before cutting the release
EDIT: I just tried to create a JDK8 application that uses the Pulsar admin client, upgrading dependency to 2.11.0-SNAPSHOT (without this pull change) and I get the expected error

java.lang.UnsupportedClassVersionError: org/apache/pulsar/packages/management/core/common/PackageName has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:757)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:473)
    at java.net.URLClassLoader.access$100 (URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged (Native Method)
    at java.net.URLClassLoader.findClass (URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:419)
    at java.lang.ClassLoader.loadClass (ClassLoader.java:352)
    at org.apache.pulsar.client.admin.internal.PackagesImpl.getMetadataAsync (PackagesImpl.java:69)
    at org.apache.pulsar.client.admin.internal.PackagesImpl.lambda$getMetadata$0 (PackagesImpl.java:64)
    at org.apache.pulsar.client.admin.internal.BaseResource.sync (BaseResource.java:292)
    at org.apache.pulsar.client.admin.internal.PackagesImpl.getMetadata (PackagesImpl.java:64)
    at com.nicoloboschi.MainClient.main (MainClient.java:26)

Main class:

public static void main(String[] args) throws Exception {
        @Cleanup
        final PulsarAdmin admin = PulsarAdmin.builder()
                .serviceHttpUrl("http://localhost:8080")
                .build();
        final PackageMetadata mypackage = admin.packages().getMetadata("mypackage");

    }

I opened a pull against 2.11 #17873

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

pulsar-client-all/pom.xml Outdated Show resolved Hide resolved
pulsar-client-all/pom.xml Outdated Show resolved Hide resolved
@Technoboy- Technoboy- added this to the 2.12.0 milestone Sep 29, 2022
@nicoloboschi nicoloboschi reopened this Sep 29, 2022
@nicoloboschi nicoloboschi marked this pull request as draft September 30, 2022 07:14
@nicoloboschi nicoloboschi marked this pull request as ready for review September 30, 2022 08:37
@nicoloboschi
Copy link
Contributor Author

/pulsarbot rerun-failure-checks

@eolivelli eolivelli merged commit 74d6305 into apache:master Sep 30, 2022
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants