Skip to content
Permalink
Browse files

Code documentation/annotation around JENKINS-28446.

Just to prevent similar misuses in the future.
  • Loading branch information...
oleg-nenashev committed May 18, 2015
1 parent 8373984 commit 298e371321b3fa3744d923554624fb94135d32ee
@@ -124,6 +124,7 @@
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.basic.AbstractSingleValueConverter;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnegative;
import jenkins.model.queue.AsynchronousExecution;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.interceptor.RequirePOST;
@@ -942,8 +943,10 @@ public boolean isPending(Task t) {

/**
* How many {@link BuildableItem}s are assigned for the given label?
* @param l Label to be checked. If null, any label will be accepted
* @return Number of {@link BuildableItem}s for the specified label.
*/
public int countBuildableItemsFor(Label l) {
public @Nonnegative int countBuildableItemsFor(@CheckForNull Label l) {
Snapshot snapshot = this.snapshot;
int r = 0;
for (BuildableItem bi : snapshot.buildables)
@@ -1808,13 +1811,16 @@ public Label getAssignedLabel() {
}

/**
* Test if the specified {@link SubTask} needs to be run on a node with a particular label, and
* return that {@link Label}. Otherwise null, indicating it can run on anywhere.
*
* Test if the specified {@link SubTask} needs to be run on a node with a particular label.
* <p>
* This code takes {@link LabelAssignmentAction} into account, then falls back to {@link SubTask#getAssignedLabel()}
* This method takes {@link LabelAssignmentAction} into account, the first
* non-null assignment will be returned.
* Otherwise falls back to {@link SubTask#getAssignedLabel()}
* @param st {@link SubTask} to be checked.
* @return Required {@link Label}. Otherwise null, indicating it can run on anywhere.
*/
public Label getAssignedLabelFor(SubTask st) {
public @CheckForNull Label getAssignedLabelFor(@Nonnull SubTask st) {
for (LabelAssignmentAction laa : getActions(LabelAssignmentAction.class)) {
Label l = laa.getAssignedLabel(st);
if (l!=null) return l;
@@ -7,6 +7,7 @@
import hudson.model.Queue.QueueDecisionHandler;
import hudson.model.Queue.Task;
import hudson.model.queue.SubTask;
import javax.annotation.Nonnull;

/**
* {@link Action} that can be submitted to {@link Queue} that controls where
@@ -35,5 +36,5 @@
* null to let other {@link LabelAssignmentAction}s take control, eventually to {@code SubTask#getAssignedLabel()}.
* If non-null value is returned, that label will be authoritative.
*/
Label getAssignedLabel(SubTask task);
Label getAssignedLabel(@Nonnull SubTask task);
}

0 comments on commit 298e371

Please sign in to comment.
You can’t perform that action at this time.