Skip to content
Permalink
Browse files
[FIXED JENKINS-40281] Do not try to mutate the result of getActions(C…
…lass).
  • Loading branch information
jglick committed Dec 8, 2016
1 parent 9172bca commit 5c79beb3efc0058d38a36a302362e69625231377
Showing with 15 additions and 0 deletions.
  1. +1 −0 core/src/main/java/hudson/model/Run.java
  2. +14 −0 test/src/test/java/hudson/model/RunTest.java
@@ -480,6 +480,7 @@ public void setResult(@Nonnull Result r) {
public @Nonnull List<BuildBadgeAction> getBadgeActions() {
List<BuildBadgeAction> r = getActions(BuildBadgeAction.class);
if(isKeepLog()) {
r = new ArrayList<>(r);
r.add(new KeepLogBuildBadge());
}
return r;
@@ -26,6 +26,8 @@
import java.net.HttpURLConnection;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static org.junit.Assert.*;
import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
@@ -59,4 +61,16 @@
j.createWebClient().assertFails("job/stuff/1/nonexistent", HttpURLConnection.HTTP_NOT_FOUND);
}

@Issue("JENKINS-40281")
@Test public void getBadgeActions() throws Exception {
FreeStyleProject p = j.createFreeStyleProject();
FreeStyleBuild b = j.buildAndAssertSuccess(p);
assertEquals(0, b.getBadgeActions().size());
assertTrue(b.canToggleLogKeep());
b.keepLog();
List<BuildBadgeAction> badgeActions = b.getBadgeActions();
assertEquals(1, badgeActions.size());
assertEquals(Run.KeepLogBuildBadge.class, badgeActions.get(0).getClass());
}

}

0 comments on commit 5c79beb

Please sign in to comment.