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

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

XMLWordPrintable

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

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

              Created:
              Updated: