jenkinsci / sonar-gerrit-plugin

Jenkins plugin for posting SonarQube issues as Gerrit review comments
https://plugins.jenkins.io/sonar-gerrit/
MIT License
27 stars 37 forks source link

`java.lang.IncompatibleClassChangeError` after upgrading to `348.v33583c89a_a_b_4` #93

Closed felipecrs closed 2 years ago

felipecrs commented 2 years ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.319.1 OS: Linux - 4.4.0-141-generic --- Parameterized-Remote-Trigger:3.1.5.1 ace-editor:1.1 allure-jenkins-plugin:2.29.0 analysis-model-api:10.8.1 ansicolor:1.0.1 ant:1.13 antisamy-markup-formatter:2.6 apache-httpcomponents-client-4-api:4.5.13-1.0 artifactory:3.15.0 async-http-client:1.9.40.0 authentication-tokens:1.4 authorize-project:1.4.0 aws-credentials:1.33 aws-java-sdk-ec2:1.12.131-302.vbef9650c6521 aws-java-sdk-minimal:1.12.131-302.vbef9650c6521 basic-branch-build-strategies:1.3.2 blueocean:1.25.2 blueocean-autofavorite:1.2.4 blueocean-bitbucket-pipeline:1.25.2 blueocean-commons:1.25.2 blueocean-config:1.25.2 blueocean-core-js:1.25.2 blueocean-dashboard:1.25.2 blueocean-display-url:2.4.1 blueocean-events:1.25.2 blueocean-git-pipeline:1.25.2 blueocean-github-pipeline:1.25.2 blueocean-i18n:1.25.2 blueocean-jwt:1.25.2 blueocean-personalization:1.25.2 blueocean-pipeline-api-impl:1.25.2 blueocean-pipeline-editor:1.25.2 blueocean-pipeline-scm-api:1.25.2 blueocean-rest:1.25.2 blueocean-rest-impl:1.25.2 blueocean-web:1.25.2 bootstrap4-api:4.6.0-3 bootstrap5-api:5.1.3-4 bouncycastle-api:2.25 branch-api:2.7.0 build-environment:1.7 build-name-setter:2.2.0 caffeine-api:2.9.2-29.v717aac953ff3 checks-api:1.7.2 cloudbees-bitbucket-branch-source:737.vdf9dc06105be cloudbees-folder:6.17 cobertura:1.17 code-coverage-api:2.0.4 command-launcher:1.6 conditional-buildstep:1.4.1 config-file-provider:3.8.2 copyartifact:1.46.2 credentials:1055.v1346ba467ba1 credentials-binding:1.27 cucumber-living-documentation:3.2 cucumber-perf:2.0.9 cucumber-reports:5.6.1 cucumber-trends-report:1.3 dark-theme:155.v497c78bbdbb3 dashboard-view:2.18 data-tables-api:1.11.3-6 display-url-api:2.3.5 docker-commons:1.17 docker-java-api:3.1.5.2 docker-plugin:1.2.6 docker-workflow:1.26 dockerhub-notification:2.5.3 dtkit-api:3.0.0 durable-task:493.v195aefbb0ff2 echarts-api:5.2.2-2 email-ext:2.86 embeddable-build-status:2.0.3 envinject:2.4.0 envinject-api:1.8 extended-choice-parameter:0.82 extended-read-permission:3.2 extensible-choice-parameter:1.8.0 external-monitor-job:1.7 favorite:2.3.3 file-parameters:146.v7d35212829d0 font-awesome-api:5.15.4-5 forensics-api:1.7.0 gerrit-code-review:0.4.7 gerrit-trigger:2.35.2 git:4.10.1 git-client:3.11.0 git-parameter:0.9.14 git-server:1.10 github:1.34.1 github-api:1.301-378.v9807bd746da5 github-autostatus:3.6.2 github-branch-source:2.11.4 gradle:1.37.1 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-1.0 htmlpublisher:1.28 ivy:2.1 jackson2-api:2.13.1-244.v773c36c5b330 jacoco:3.3.1 javadoc:1.6 jaxb:2.3.0.1 jdk-tool:1.5 jenkins-design-language:1.25.2 jira:3.6 jjwt-api:0.11.2-9.c8b45b8bb173 jobConfigHistory:2.31-rc1098.b666422863b2 jquery:1.12.4-1 jquery-detached:1.2.1 jquery3-api:3.6.0-2 jsch:0.1.55.2 junit:1.53 kubernetes:1.31.2 kubernetes-client-api:5.11.1-179.v12037658df90 kubernetes-credentials:0.9.0 last-changes:2.7.11 ldap:2.7 lockable-resources:2.13 mailer:1.34 mapdb-api:1.0.9.0 matrix-auth:2.6.11 matrix-project:1.19 maven-plugin:3.16 metrics:4.0.2.8 momentjs:1.1.1 monitoring:1.90.0 multibranch-build-strategy-extension:1.0.10 okhttp-api:4.9.3-105.vb96869f8ac3a pam-auth:1.6.1 parameterized-trigger:2.43 pipeline-build-step:2.15 pipeline-graph-analysis:188.v3a01e7973f2c pipeline-input-step:427.va6441fa17010 pipeline-milestone-step:1.3.2 pipeline-model-api:1.9.3 pipeline-model-definition:1.9.3 pipeline-model-extensions:1.9.3 pipeline-rest-api:2.20 pipeline-stage-step:291.vf0a8a7aeeb50 pipeline-stage-tags-metadata:1.9.3 pipeline-stage-view:2.20 pipeline-utility-steps:2.11.0 plain-credentials:1.7 plugin-util-api:2.10.0 popper-api:1.16.1-2 popper2-api:2.11.0-1 pubsub-light:1.16 purge-build-queue-plugin:1.0 rebuild:1.32 resource-disposer:0.17 role-strategy:3.2.0 run-condition:1.5 saferestart:0.3 scm-api:2.6.5 scm-filter-branch-pr:0.5.1 script-security:1118.vba21ca2e3286 snakeyaml-api:1.29.1 sonar:2.14 sonar-gerrit:348.v33583c89a_a_b_4 sse-gateway:1.24 ssh-credentials:1.19 ssh-slaves:1.33.0 sshd:3.1.0 strict-crumb-issuer:2.1.0 structs:308.v852b473a2b8c subversion:2.15.1 theme-manager:0.6 timestamper:1.15 token-macro:267.vcdaea6462991 trilead-api:1.0.13 uno-choice:2.5.7 variant:1.4 windows-slaves:1.8 workflow-aggregator:2.6 workflow-api:1108.v57edf648f5d4 workflow-basic-steps:2.24 workflow-cps:2648.va9433432b33c workflow-cps-global-lib:552.vd9cc05b8a2e1 workflow-durable-task-step:1112.vda00e6febcc1 workflow-job:1145.v7f2433caa07f workflow-multibranch:696.v52535c46f4c9 workflow-scm-step:2.13 workflow-step-api:615.vb09dac339255 workflow-support:804.vba10a18a1476 ws-cleanup:0.40 xunit:3.0.5 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

Using Jenkins as docker (jdk11)

Reproduction steps

  1. Have a working setup with v2.4.6
  2. Upgrade to 348.v33583c89a_a_b_4

Expected Results

To work as it did before.

Actual Results

java.lang.IncompatibleClassChangeError: Class com.google.common.base.Suppliers$MemoizingSupplier does not implement the requested interface java.util.function.Supplier
    at com.urswolfer.gerrit.client.rest.GerritApiImpl.changes(GerritApiImpl.java:122)
    at org.jenkinsci.plugins.sonargerrit.review.GerritConnector.getRevision(GerritConnector.java:55)
    at org.jenkinsci.plugins.sonargerrit.SonarToGerritPublisher.perform(SonarToGerritPublisher.java:134)
    at jenkins.tasks.SimpleBuildStep.perform(SimpleBuildStep.java:123)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:100)
    at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:70)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)

Anything else?

Downgrading the plugin back to 2.4.6 solves the issue.

https://updates.jenkins-ci.org/download/plugins/sonar-gerrit/2.4.6/sonar-gerrit.hpi

reda-alaoui commented 2 years ago

Thanks for the report. I will take a look at this asap.

felipecrs commented 2 years ago

Thanks for the report. I will take a look at this asap.

Np :)

felipecrs commented 2 years ago

Thanks a lot, I will test the new version!

felipecrs commented 2 years ago

Works like a charm. Again, thanks a lot, and happy new year!

uwolfer commented 2 years ago

@reda-alaoui: I have just noticed this change which started using a shaded version of gerrit-rest-java-client. Do you remember the reasons for this change? I would be happy to provide a solution with the library itself if possible.

reda-alaoui commented 2 years ago

Hi @uwolfer ,

Thank you for trying to help :)

The reason is that Jenkins plugins share the same classloader. Therefore without shading there is no guarantee that a plugin will use the expected version of its dependencies at runtime.

There is another Jenkins plugin that uses an older version of your library.

So I am not sure you can do anything about that.

Here is more material about that: https://www.jenkins.io/doc/developer/plugin-development/dependencies-and-class-loading/

uwolfer commented 2 years ago

Thanks @reda-alaoui for the explanation - got it!

In the long run, it would probably make sense to use the approach "Using library wrapper plugins", which just provides gerrit-rest-java-client, and all plugins using this lib would depend on it (I hope I got this approach right).

In general, I try to not break API backwards compatibility anyway, so such a breakage should hopefully not happen to often, and the lib should work with outdated peer-dependencies.

reda-alaoui commented 2 years ago

In the long run, it would probably make sense to use the approach "Using library wrapper plugins", which just provides gerrit-rest-java-client, and all plugins using this lib would depend on it (I hope I got this approach right).

Agreed but this requires coordination with the Jenkins community. Too much effort given the time I can give to this project :/