提交 da67b374 编写于 作者: J Jesse Glick 提交者: Oliver Gondža

[FIXED JENKINS-42969] UnsupportedOperationException from Computer.addAction.

(cherry picked from commit 83835770)
上级 130a2ad5
...@@ -1046,6 +1046,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A ...@@ -1046,6 +1046,8 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A
return Collections.unmodifiableList(actions); return Collections.unmodifiableList(actions);
} }
// TODO implement addAction, addOrReplaceAction, removeAction, removeActions, replaceActions
/** /**
* Gets the {@link Node} where this project was last built on. * Gets the {@link Node} where this project was last built on.
* *
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
package hudson.model; package hudson.model;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.EnvVars; import hudson.EnvVars;
import hudson.Extension; import hudson.Extension;
import hudson.Launcher.ProcStarter; import hudson.Launcher.ProcStarter;
...@@ -268,6 +269,18 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces ...@@ -268,6 +269,18 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
return Collections.unmodifiableList(result); return Collections.unmodifiableList(result);
} }
@SuppressWarnings({"ConstantConditions","deprecation"})
@SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE")
@Override
public void addAction(@Nonnull Action a) {
if (a == null) {
throw new IllegalArgumentException("Action must be non-null");
}
super.getActions().add(a);
}
// TODO implement addOrReplaceAction, removeAction, removeActions, replaceActions
/** /**
* This is where the log from the remote agent goes. * This is where the log from the remote agent goes.
* The method also creates a log directory if required. * The method also creates a log directory if required.
......
...@@ -106,6 +106,8 @@ public class LabelAtom extends Label implements Saveable { ...@@ -106,6 +106,8 @@ public class LabelAtom extends Label implements Saveable {
return Collections.unmodifiableList(actions); return Collections.unmodifiableList(actions);
} }
// TODO implement addAction, addOrReplaceAction, removeAction, removeActions, replaceActions
protected void updateTransientActions() { protected void updateTransientActions() {
Vector<Action> ta = new Vector<Action>(); Vector<Action> ta = new Vector<Action>();
......
...@@ -31,7 +31,6 @@ import static org.junit.Assert.*; ...@@ -31,7 +31,6 @@ import static org.junit.Assert.*;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.html.HtmlForm; import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.xml.XmlPage; import com.gargoylesoftware.htmlunit.xml.XmlPage;
import java.io.File; import java.io.File;
...@@ -40,7 +39,6 @@ import jenkins.model.Jenkins; ...@@ -40,7 +39,6 @@ import jenkins.model.Jenkins;
import hudson.slaves.DumbSlave; import hudson.slaves.DumbSlave;
import hudson.slaves.OfflineCause; import hudson.slaves.OfflineCause;
import org.junit.Before;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.Issue;
...@@ -114,4 +112,17 @@ public class ComputerTest { ...@@ -114,4 +112,17 @@ public class ComputerTest {
assertThat(content, not(containsString("ApiTokenProperty"))); assertThat(content, not(containsString("ApiTokenProperty")));
assertThat(content, not(containsString("apiToken"))); assertThat(content, not(containsString("apiToken")));
} }
@Issue("JENKINS-42969")
@Test
public void addAction() throws Exception {
Computer c = j.createSlave().toComputer();
class A extends InvisibleAction {}
assertEquals(0, c.getActions(A.class).size());
c.addAction(new A());
assertEquals(1, c.getActions(A.class).size());
c.addAction(new A());
assertEquals(2, c.getActions(A.class).size());
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册