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

"IllegalArgumentException: Collection is empty" when processing emtpy Cobertura results

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: cobertura-plugin
    • Labels:
      None
    • Environment:
      Hudson 1.355, Cobertura plugin 0.8.11
    • Similar Issues:

      Description

      My build for some reasons produces an empty Cobertura report, like this:

      <?xml version="1.0" ?>
      <!DOCTYPE coverage
        SYSTEM 'http://cobertura.sourceforge.net/xml/coverage-03.dtd'>
      <coverage>
      	<sources>
      		<source>
      			/private/var/lib/hudson/workspace/myproj/client
      		</source>
      	</sources>
      	<packages/>
      </coverage>
      

      Whenever I load the project page or the Cobertura report page, I get an exception in the server log:

      2010-maj-03 13:44:49 hudson.ExpressionFactory2$JexlExpression evaluate
      VARNING: Caught exception evaluating: it.metrics. Reason: java.lang.reflect.InvocationTargetException
      java.lang.reflect.InvocationTargetException
              at sun.reflect.GeneratedMethodAccessor548.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:616)
              at org.apache.commons.jexl.util.PropertyExecutor.execute(PropertyExecutor.java:125)
              at org.apache.commons.jexl.util.introspection.UberspectImpl$VelGetterImpl.invoke(UberspectImpl.java:314)
              at org.apache.commons.jexl.parser.ASTArrayAccess.evaluateExpr(ASTArrayAccess.java:185)
              at org.apache.commons.jexl.parser.ASTIdentifier.execute(ASTIdentifier.java:75)
              at org.apache.commons.jexl.parser.ASTReference.execute(ASTReference.java:83)
              at org.apache.commons.jexl.parser.ASTReference.value(ASTReference.java:57)
              at org.apache.commons.jexl.parser.ASTReferenceExpression.value(ASTReferenceExpression.java:51)
              at org.apache.commons.jexl.ExpressionImpl.evaluate(ExpressionImpl.java:80)
              at hudson.ExpressionFactory2$JexlExpression.evaluate(ExpressionFactory2.java:72)
              at org.apache.commons.jelly.tags.core.CoreTagLibrary$3.run(CoreTagLibrary.java:134)
              at org.apache.commons.jelly.impl.ScriptBlock.run(ScriptBlock.java:95)
              at org.kohsuke.stapler.jelly.CallTagLibScript$1.run(CallTagLibScript.java:75)
              at org.apache.commons.jelly.tags.define.InvokeBodyTag.doTag(InvokeBodyTag.java:91)
              at org.apache.commons.jelly.impl.TagScript.run(TagScript.java:270)
      ...
      Caused by: java.lang.IllegalArgumentException: Collection is empty
              at java.util.EnumSet.copyOf(EnumSet.java:166)
              at hudson.plugins.cobertura.targets.CoverageResult.getMetrics(CoverageResult.java:331)
              ... 92 more
      

        Attachments

          Activity

          Hide
          ldore ldore added a comment -

          Changing the method hudson.plugins.cobertura.targets.CoverageResult.CoverageResult.getMetrics (Near line 326 in CoverageResult.java) to

            public Set<CoverageMetric> getMetrics() {
              if (aggregateResults.keySet().size() != 0) {
                return Collections.unmodifiableSet(EnumSet.copyOf(aggregateResults.keySet()));
              }
              else {
                return Collections.unmodifiableSet(new TreeSet<CoverageMetric>());
              }
            }
          

          makes the exception disappear. I'm not sure this is the correct fix, though:
          Could the aggregateResults be emptied between the size check and the copyOf call ?

          Show
          ldore ldore added a comment - Changing the method hudson.plugins.cobertura.targets.CoverageResult.CoverageResult.getMetrics (Near line 326 in CoverageResult.java ) to public Set<CoverageMetric> getMetrics() { if (aggregateResults.keySet().size() != 0) { return Collections.unmodifiableSet(EnumSet.copyOf(aggregateResults.keySet())); } else { return Collections.unmodifiableSet( new TreeSet<CoverageMetric>()); } } makes the exception disappear. I'm not sure this is the correct fix, though: Could the aggregateResults be emptied between the size check and the copyOf call ?
          Hide
          stephenconnolly Stephen Connolly added a comment -

          Last two releases (separated by over a year) were by Oliver Gondža so looks like the maintainer

          Show
          stephenconnolly Stephen Connolly added a comment - Last two releases (separated by over a year) were by Oliver Gondža so looks like the maintainer
          Hide
          bollenn Nico Bollen added a comment -

          I ran into something similar so I created:
          https://github.com/jenkinsci/cobertura-plugin/pull/56

          Show
          bollenn Nico Bollen added a comment - I ran into something similar so I created: https://github.com/jenkinsci/cobertura-plugin/pull/56
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Michael Barrientos
          Path:
          src/main/java/hudson/plugins/cobertura/targets/CoverageResult.java
          http://jenkins-ci.org/commit/cobertura-plugin/119614917d8f6ffc7583b05b9fd18724da1ec4bd
          Log:
          JENKINS-6425 Avoid EnumSet.copyOf of empty sets

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michael Barrientos Path: src/main/java/hudson/plugins/cobertura/targets/CoverageResult.java http://jenkins-ci.org/commit/cobertura-plugin/119614917d8f6ffc7583b05b9fd18724da1ec4bd Log: JENKINS-6425 Avoid EnumSet.copyOf of empty sets
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Michael Barrientos
          Path:
          src/main/java/hudson/plugins/cobertura/targets/CoverageResult.java
          http://jenkins-ci.org/commit/cobertura-plugin/2c4f8d91d7e63426738b4885166a416a6d944442
          Log:
          Merge pull request #66 from mbarrien/empty-enumset

          JENKINS-6425 Avoid EnumSet.copyOf of empty sets

          Compare: https://github.com/jenkinsci/cobertura-plugin/compare/1cf41b4edc3c...2c4f8d91d7e6

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Michael Barrientos Path: src/main/java/hudson/plugins/cobertura/targets/CoverageResult.java http://jenkins-ci.org/commit/cobertura-plugin/2c4f8d91d7e63426738b4885166a416a6d944442 Log: Merge pull request #66 from mbarrien/empty-enumset JENKINS-6425 Avoid EnumSet.copyOf of empty sets Compare: https://github.com/jenkinsci/cobertura-plugin/compare/1cf41b4edc3c...2c4f8d91d7e6
          Show
          mbarrien Michael Barrientos added a comment - Closed in  https://github.com/jenkinsci/cobertura-plugin/pull/66

            People

            • Assignee:
              mbarrien Michael Barrientos
              Reporter:
              mbetter Marcus Better
            • Votes:
              3 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: