Skip to content
Permalink
Browse files

Code documentation/annotation around JENKINS-28446.

Just to prevent similar misuses in the future.

(cherry picked from commit 298e371)
  • Loading branch information...
oleg-nenashev authored and olivergondza committed May 18, 2015
1 parent c7264c4 commit de5d83de09d2f0ec47292691da063a8eb43846f0
@@ -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;
@@ -937,8 +938,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)
@@ -1801,13 +1804,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 de5d83d

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.