Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-58279

Sonar gerrit plugin fails with ClassCastException on java 11

    Details

    • Similar Issues:

      Description

      We run jenkins in a docker container and integrate to a gerrit server using the gerrit-trigger and sonar-gerrit plugins.
      Recently we updated our jenkins server from java 8 to java 11, and encountered an error with the sonar-gerrit plugin.

      It fails in the post-build step due to a ClassCastException.
      The error logged is this:

      Recording test results
      Getting Sonar Report from: /var/jenkins_home/workspace/cloud-visits/build/sonar/sonar-report.json
      Report has loaded and contains 2 issues
      ERROR: Build step failed with exception
      java.lang.ClassCastException: class [Ljava.lang.Object; cannot be cast to class [Ljava.lang.String; ([Ljava.lang.Object; and [Ljava.lang.String; are in module java.base of loader 'bootstrap')
      at org.jenkinsci.plugins.sonargerrit.SonarToGerritPublisher.perform(SonarToGerritPublisher.java:112)
      at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:79)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
      at hudson.model.Build$BuildExecution.post2(Build.java:186)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
      at hudson.model.Run.execute(Run.java:1843)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:97)
      at hudson.model.Executor.run(Executor.java:429)
      Build step 'Post SonarQube issues as Gerrit comments' marked build as failure

      We did some digging around and this is a related JDK change that changes the return type of toArray():
      https://bugs.openjdk.java.net/browse/JDK-8176893

      Attached is a patch file that we have used to make a local build of the plugin that works fine in our environment.

        Attachments

          Activity

          Hide
          batmat Baptiste Mathus added a comment -

          Peter Kristensson hello! I think if you want to move this forward, it would be even easier for the maintainer if a PR can be submitted against https://github.com/jenkinsci/sonar-gerrit-plugin directly.

          We can help you to do that if you are willing to help.

          Thanks a lot for the fix!

          Show
          batmat Baptiste Mathus added a comment - Peter Kristensson hello! I think if you want to move this forward, it would be even easier for the maintainer if a PR can be submitted against https://github.com/jenkinsci/sonar-gerrit-plugin directly. We can help you to do that if you are willing to help. Thanks a lot for the fix!
          Hide
          peterkristensson Peter Kristensson added a comment -

          Baptiste Mathus Hi, I can certainly do a pull request on that repository. My github userid is "kripe".

          //Peter

          Show
          peterkristensson Peter Kristensson added a comment - Baptiste Mathus Hi, I can certainly do a pull request on that repository. My github userid is "kripe". //Peter
          Hide
          egutierrez Evaristo Gutierrez added a comment -

          Peter Kristensson I have not seen any PR on the repository. Can we help you in any way?

           

          Show
          egutierrez Evaristo Gutierrez added a comment - Peter Kristensson I have not seen any PR on the repository. Can we help you in any way?  
          Hide
          peterkristensson Peter Kristensson added a comment -

          Sorry I was a bit slow on getting that done.

          A new PR is now available here: https://github.com/jenkinsci/sonar-gerrit-plugin/pull/37

          Show
          peterkristensson Peter Kristensson added a comment - Sorry I was a bit slow on getting that done. A new PR is now available here:  https://github.com/jenkinsci/sonar-gerrit-plugin/pull/37

            People

            • Assignee:
              aquarellian Tatiana Didik
              Reporter:
              peterkristensson Peter Kristensson
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: