Add annotations as documented (#6325)

This commit is contained in:
offa 2022-03-03 15:09:54 +00:00 committed by GitHub
parent 66cd7821d3
commit 99ae887070
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 5 deletions

View File

@ -24,6 +24,7 @@
package hudson.model;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.ExtensionList;
import hudson.ExtensionPoint;
@ -57,5 +58,5 @@ public abstract class LabelFinder implements ExtensionPoint {
* @return
* A set of labels for the node. Can be empty but never null.
*/
public abstract Collection<LabelAtom> findLabels(Node node);
public abstract @NonNull Collection<LabelAtom> findLabels(@NonNull Node node);
}

View File

@ -25,6 +25,8 @@
package hudson.model;
import com.google.common.collect.Maps;
import edu.umd.cs.findbugs.annotations.CheckForNull;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.ExtensionPoint;
import hudson.model.Queue.Task;
@ -71,14 +73,16 @@ public abstract class LoadBalancer implements ExtensionPoint {
* Return null if you don't want the task to be executed right now,
* in which case this method will be called some time later with the same task.
*/
public abstract Mapping map(Task task, MappingWorksheet worksheet);
@CheckForNull
public abstract Mapping map(@NonNull Task task, MappingWorksheet worksheet);
/**
* Uses a consistent hash for scheduling.
*/
public static final LoadBalancer CONSISTENT_HASH = new LoadBalancer() {
@CheckForNull
@Override
public Mapping map(Task task, MappingWorksheet ws) {
public Mapping map(@NonNull Task task, MappingWorksheet ws) {
// build consistent hash for each work chunk
List<ConsistentHash<ExecutorChunk>> hashes = new ArrayList<>(ws.works.size());
for (int i = 0; i < ws.works.size(); i++) {
@ -152,8 +156,9 @@ public abstract class LoadBalancer implements ExtensionPoint {
protected LoadBalancer sanitize() {
final LoadBalancer base = this;
return new LoadBalancer() {
@CheckForNull
@Override
public Mapping map(Task task, MappingWorksheet worksheet) {
public Mapping map(@NonNull Task task, MappingWorksheet worksheet) {
if (Queue.isBlockedByShutdown(task)) {
// if we are quieting down, don't start anything new so that
// all executors will be eventually free.

View File

@ -37,6 +37,7 @@ import static org.junit.Assert.fail;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.WebRequest;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.EnvVars;
import hudson.FilePath;
import hudson.model.Node.Mode;
@ -429,8 +430,9 @@ public class NodeTest {
@TestExtension
public static class LabelFinderImpl extends LabelFinder {
@NonNull
@Override
public Collection<LabelAtom> findLabels(Node node) {
public Collection<LabelAtom> findLabels(@NonNull Node node) {
List<LabelAtom> atoms = new ArrayList<>();
if (addDynamicLabel) {
atoms.add(Jenkins.get().getLabelAtom("dynamicLabel"));