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

EmmaCoverageColumn: Fix NullPointerException in logfile if projects do not have coverage data (yet)

      The following patch will prevent the plugin from showing NullPointerExceptions in the logfile if projects are not run yet or did not yet report coverage data.

      diff --git a/src/main/java/jenkins/plugins/emmacoveragecolumn/EmmaColumn.java b/src/main/java/jenkins/plugins/emmacoveragecolumn/EmmaColumn.java
      index 34fe2c0..e60897a 100644
      --- a/src/main/java/jenkins/plugins/emmacoveragecolumn/EmmaColumn.java
      +++ b/src/main/java/jenkins/plugins/emmacoveragecolumn/EmmaColumn.java
      @@ -76,9 +76,17 @@ public class EmmaColumn extends ListViewColumn {
              }
       
              private Float getPercentageFloat(final Run<?, ?> lastSuccessfulBuild) {
      +               if(lastSuccessfulBuild == null) {
      +                       return new Float(0);
      +               }
      +
                      final EmmaBuildAction action = lastSuccessfulBuild
                                      .getAction(EmmaBuildAction.class);
       
      +               if(action == null) {
      +                       return new Float(0);
      +               }
      +
                      final CoverageReport result = action.getResult();
       
                      final Ratio ratio = result.getLineCoverage();
      

          [JENKINS-12230] EmmaCoverageColumn: Fix NullPointerException in logfile if projects do not have coverage data (yet)

          Adam Sloan added a comment -

          Shows Black "N/A%" bars, and no more NPE's - thanks!

          Adam Sloan added a comment - Shows Black "N/A%" bars, and no more NPE's - thanks!

          Could this issue please be escalated? This issue currently gives approximately 1 gig of log data per week in our setup.

          Stig Runar Vangen added a comment - Could this issue please be escalated? This issue currently gives approximately 1 gig of log data per week in our setup.

          David Miller added a comment -

          I recently started adding Emma code coverage functionality to some of our Jenkins jobs and got a nasty surprise when the Jenkins log file spiked to 20 GB because of this issue. I can do a "tail -f" on the log and see the error messages go in every time I navigate around the Jenkins web UI. I, too, would like to see this issue escalated. We are not building jenkins from source, so would need a real update. Thanks.

          David Miller added a comment - I recently started adding Emma code coverage functionality to some of our Jenkins jobs and got a nasty surprise when the Jenkins log file spiked to 20 GB because of this issue. I can do a "tail -f" on the log and see the error messages go in every time I navigate around the Jenkins web UI. I, too, would like to see this issue escalated. We are not building jenkins from source, so would need a real update. Thanks.

          centic added a comment -

          In the meantime I switched to using the JaCoCo plugin, this also contains the same functionality as the EmmaCoverageColumn plugin and has this issue fixed. I think the Emma-plugins are deprecated now anyway as far as I saw.

          centic added a comment - In the meantime I switched to using the JaCoCo plugin, this also contains the same functionality as the EmmaCoverageColumn plugin and has this issue fixed. I think the Emma-plugins are deprecated now anyway as far as I saw.

          David Miller added a comment -

          Hi Centic: If you switched to the JaCoCo plugin, I presume you also had to switch to using the JaCoCo tool? Unless I missed something, I didn't see that the JaCoCo plugin accepted Emma output. If so, that would mean redoing our code coverage automation to use a different tool. I would hate to have to do that since Emma has been working just fine for us for several years.

          David Miller added a comment - Hi Centic: If you switched to the JaCoCo plugin, I presume you also had to switch to using the JaCoCo tool? Unless I missed something, I didn't see that the JaCoCo plugin accepted Emma output. If so, that would mean redoing our code coverage automation to use a different tool. I would hate to have to do that since Emma has been working just fine for us for several years.

          centic added a comment -

          Yes, that is unfortunately correct, however as Emma itself is deprecated in favour of JaCoCo as well you will likely need to upgrade at some point. I would expect that at least when you switch to Java 7 you will need JaCoCo for code coverage measurement to work properly.

          centic added a comment - Yes, that is unfortunately correct, however as Emma itself is deprecated in favour of JaCoCo as well you will likely need to upgrade at some point. I would expect that at least when you switch to Java 7 you will need JaCoCo for code coverage measurement to work properly.

            Unassigned Unassigned
            centic centic
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: