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

No Badge shown, Exception build.badgeActions depending on KeepBuildForever

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • core

      After Update to Jenkins 2.34 and 2.35 we see several exceptions "WARNING: Caught exception evaluating: build.badgeActions" (see below) in the log file. We could easily reproduce this in a fresh new setup without additional installed plugins by:

      • Setup a new Build-Job and activate "Discard old builds".
      • Execute this job.
      • Navigate to the build and activate "Keep this build forever"
      • Access the job site.
        • => Exception in log file (see below)
        • => Lock icon "KeepBuild" not shown. In case of promotions the icons also not appear.

      After deactivating "Keep this build forever" the exception does not appear and promotion icons/stars appear again.

      Exception:

      … hudson.ExpressionFactory2$JexlExpression evaluate
      WARNING: Caught exception evaluating: build.badgeActions in /job/test/. Reason: java.lang.reflect.InvocationTargetException
      java.lang.reflect.InvocationTargetException
              at …
      Caused by: java.lang.UnsupportedOperationException
              at java.util.Collections$UnmodifiableCollection.add(Collections.java:1055)
              at hudson.model.Run.getBadgeActions(Run.java:483)
              ... 161 more
      

          [JENKINS-40281] No Badge shown, Exception build.badgeActions depending on KeepBuildForever

          Ed added a comment -

          Experiencing the same problem in 2.35 on Ubuntu 14.04 delivered via Ubuntu package. I think the problem originated in commit 6360b96464f6c2498fe91a089a21992411b2ec34 (https://github.com/jenkinsci/jenkins/commit/6360b96464f6c2498fe91a089a21992411b2ec34) for issue JENKINS-38867. In `Actionable.java:138`, the change introduced return of the badge actions with `Collections.unmodifiableList()`. The list returned to caller `Run.getBadgeActions()` is then immediately added to, causing the exception.

          From Run.java:480:

          public @Nonnull List<BuildBadgeAction> getBadgeActions() {
                  List<BuildBadgeAction> r = getActions(BuildBadgeAction.class); // This is now an unmodifiableList.
                  if(isKeepLog()) {
                      r.add(new KeepLogBuildBadge()); // Can't add to an unmodifiable List, so an exception is thrown.
                  }
                  return r;
              }
          

          Ed added a comment - Experiencing the same problem in 2.35 on Ubuntu 14.04 delivered via Ubuntu package. I think the problem originated in commit 6360b96464f6c2498fe91a089a21992411b2ec34 ( https://github.com/jenkinsci/jenkins/commit/6360b96464f6c2498fe91a089a21992411b2ec34 ) for issue JENKINS-38867 . In `Actionable.java:138`, the change introduced return of the badge actions with `Collections.unmodifiableList()`. The list returned to caller `Run.getBadgeActions()` is then immediately added to, causing the exception. From Run.java:480: public @Nonnull List<BuildBadgeAction> getBadgeActions() { List<BuildBadgeAction> r = getActions(BuildBadgeAction.class); // This is now an unmodifiableList. if (isKeepLog()) { r.add( new KeepLogBuildBadge()); // Can't add to an unmodifiable List, so an exception is thrown. } return r; }

          Jesse Glick added a comment -

          From quick code inspection, I believe this was the only such case in Jenkins core. And, the associated keepLog functionality had zero test coverage.

          Jesse Glick added a comment - From quick code inspection, I believe this was the only such case in Jenkins core. And, the associated keepLog functionality had zero test coverage.

          Code changed in jenkins
          User: Jesse Glick
          Path:
          core/src/main/java/hudson/model/Run.java
          test/src/test/java/hudson/model/RunTest.java
          http://jenkins-ci.org/commit/jenkins/5c79beb3efc0058d38a36a302362e69625231377
          Log:
          [FIXED JENKINS-40281] Do not try to mutate the result of getActions(Class).

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: core/src/main/java/hudson/model/Run.java test/src/test/java/hudson/model/RunTest.java http://jenkins-ci.org/commit/jenkins/5c79beb3efc0058d38a36a302362e69625231377 Log: [FIXED JENKINS-40281] Do not try to mutate the result of getActions(Class).

          Daniel Beck added a comment -

          Fixed in 2.36

          Daniel Beck added a comment - Fixed in 2.36

            jglick Jesse Glick
            h_hermanns Horst Hermanns
            Votes:
            1 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: