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

Clover-Plugin NullPointer exception on build when <failingTarget> config is missing

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • clover-plugin
    • None

      Clover Plugin throws an NPE on build.. find exception below. Our team was able to debug the issue and it was due to missing <failingTarget> config for clover publisher because the failing target fields were not populated. As you can see, this error is not helpful and it would be nice if the log can be more helpful in case of a missing config.

      The NPE happens exactly at this line in CloverPublisher.java
      Set<CoverageMetric> failingMetrics = failingTarget.getFailingMetrics(result);
      where failingTarget is null.. well because it was not provided in the xml config.

      Disclaimer: I have not developed jenkins plugins before so I appologize if I'm not using correct terms.

      ERROR: Build step failed with exception
      java.lang.NullPointerException
      at hudson.plugins.clover.CloverPublisher.processCloverXml(CloverPublisher.java:250)
      at hudson.plugins.clover.CloverPublisher.performImpl(CloverPublisher.java:202)
      at hudson.plugins.clover.CloverPublisher.perform(CloverPublisher.java:160)
      at hudson.tasks.BuildStepMonitor$3.perform(BuildStepMonitor.java:45)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:764)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:724)
      at hudson.maven.MavenModuleSetBuild$MavenModuleSetBuildExecution.post2(MavenModuleSetBuild.java:1047)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:671)
      at hudson.model.Run.execute(Run.java:1769)
      at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:374)

          [JENKINS-40297] Clover-Plugin NullPointer exception on build when <failingTarget> config is missing

          Fedor Petryk added a comment -

          Same here.
          The report is publishing but build status is setting to failure.

          Fedor Petryk added a comment - Same here. The report is publishing but build status is setting to failure.

          Bjørn Reppen added a comment - - edited

          Same exception here. Wrapping it in a try/catch block as a temporary workaround works.

          Bjørn Reppen added a comment - - edited Same exception here. Wrapping it in a try/catch block as a temporary workaround works.

          bjornr NullPointerExceptions are meant to be fixed, not caught. The underlying problem is that failingTarget is NULL and that is what needs to be fixed with a default value OR at least a Log message to remind the user to add those failingTarget values.

          Ahmed Musallam added a comment - bjornr NullPointerExceptions are meant to be fixed, not caught. The underlying problem is that failingTarget is NULL and that is what needs to be fixed with a default value OR at least a Log message to remind the user to add those failingTarget values.

          Can you confirm that this still happens in the latest Jenkins Clover Plugin - version 4.7.1?

          I'm asking because in this version I fixed NPE and closed two other tickets: JENKINS-38956 and JENKINS-39410 which look very similar to yours.

          I suspect that this bug report can be closed too.

          Marek Parfianowicz added a comment - Can you confirm that this still happens in the latest Jenkins Clover Plugin - version 4.7.1 ? I'm asking because in this version I fixed NPE and closed two other tickets: JENKINS-38956  and JENKINS-39410  which look very similar to yours. I suspect that this bug report can be closed too.

          mparfianowicz looking at the code, it seems the issue was fixed! and that NPE will not happen. Thanks!
          As to testing it on a Jenkins instance, please give me some time to run a local instance and install 4.7.1. Or if anyone wants to confirm, use the follwing config:
          <publishers>
          <hudson.plugins.clover.CloverPublisher plugin="clover@4.7.0">
          <cloverReportDir>target/site/clover</cloverReportDir>
          <cloverReportFileName>clover.xml</cloverReportFileName>
          <healthyTarget>
          <methodCoverage>70</methodCoverage>
          <conditionalCoverage>80</conditionalCoverage>
          <statementCoverage>80</statementCoverage>
          </healthyTarget>
          </hudson.plugins.clover.CloverPublisher>
          </publishers>

          Ahmed Musallam added a comment - mparfianowicz looking at the code, it seems the issue was fixed! and that NPE will not happen. Thanks! As to testing it on a Jenkins instance, please give me some time to run a local instance and install 4.7.1. Or if anyone wants to confirm, use the follwing config: <publishers> <hudson.plugins.clover.CloverPublisher plugin="clover@4.7.0"> <cloverReportDir>target/site/clover</cloverReportDir> <cloverReportFileName>clover.xml</cloverReportFileName> <healthyTarget> <methodCoverage>70</methodCoverage> <conditionalCoverage>80</conditionalCoverage> <statementCoverage>80</statementCoverage> </healthyTarget> </hudson.plugins.clover.CloverPublisher> </publishers>

          CloverPublisher since 9.12.2016 has:

          final Set<CoverageMetric> failingMetrics = failingTarget != null
                  ? failingTarget.getFailingMetrics(result)
                  : Collections.<CoverageMetric>emptySet()

          Fixed in Jenkins Clover Plugin 4.7.1+ and 4.8.0+

          Marek Parfianowicz added a comment - CloverPublisher since 9.12.2016 has: final Set<CoverageMetric> failingMetrics = failingTarget != null ? failingTarget.getFailingMetrics(result) : Collections.<CoverageMetric>emptySet() Fixed in Jenkins Clover Plugin 4.7.1+ and 4.8.0+

            marekparf Marek Parfianowicz
            ahmedmusallam Ahmed Musallam
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: