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

Sonar gerrit plugin fails with ClassCastException on java 11


    • 2.4

      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():

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

            aquarellian Tatiana Didik
            peterkristensson Peter Kristensson
            0 Vote for this issue
            3 Start watching this issue