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

UnstableJobsPortlet throw java.lang.ClassCastException in getUnstableJobs method

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • dashboard-view-plugin
    • None
    • Jenkins: 1.572
      SO: Ubuntu 12.04 LTS
    • dashboard-view 2.9.4

      After the last updates the portlet throw the next error:

      WARNING: Caught exception evaluating: it.getUnstableJobs(jobs) in /. Reason: java.lang.ClassCastException: hudson.maven.MavenModule cannot be cast to hudson.model.TopLev                              elItem
      java.lang.ClassCastException: hudson.maven.MavenModule cannot be cast to hudson.model.TopLevelItem
              at hudson.plugins.view.dashboard.core.UnstableJobsPortlet.getUnstableJobs(UnstableJobsPortlet.java:44)
              at hudson.plugins.view.dashboard.core.UnstableJobsPortlet.getUnstableJobs(UnstableJobsPortlet.java:46)
              at sun.reflect.GeneratedMethodAccessor597.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      

      Seeing the conde and the class hierarchy, I think that the correct method signature for getUnstableJobs is:

         public Collection<Job> getUnstableJobs(Collection<Item> allJobs) {
            ArrayList<Job> unstableJobs = new ArrayList<Job>();
      
             for (Item item : allJobs) {
      
                 ....
             }
      
             ....
      }
      

      With this change I think that we avoid the error.

            petehayes Peter Hayes
            jrpedrianes Jorge Rodríguez Pedrianes
            Votes:
            9 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: