提交 2eb43ff9 编写于 作者: J Jesse Glick

Adding some nullness annotations related to Job.getEnvironment.

Cf.: https://github.com/jenkinsci/subversion-plugin/pull/83
上级 7c620e9f
...@@ -918,7 +918,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces ...@@ -918,7 +918,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
* @see ProcStarter#envs(Map) * @see ProcStarter#envs(Map)
* @since 1.489 * @since 1.489
*/ */
public EnvVars buildEnvironment(TaskListener listener) throws IOException, InterruptedException { public @Nonnull EnvVars buildEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env = new EnvVars(); EnvVars env = new EnvVars();
Node node = getNode(); Node node = getNode();
......
...@@ -31,6 +31,7 @@ import hudson.scm.SCM; ...@@ -31,6 +31,7 @@ import hudson.scm.SCM;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import java.io.IOException; import java.io.IOException;
import javax.annotation.Nonnull;
/** /**
* Contributes environment variables to builds. * Contributes environment variables to builds.
...@@ -79,14 +80,14 @@ public abstract class EnvironmentContributor implements ExtensionPoint { ...@@ -79,14 +80,14 @@ public abstract class EnvironmentContributor implements ExtensionPoint {
* variables that are scoped to builds. * variables that are scoped to builds.
* *
* @param r * @param r
* Build that's being performed. Never null. * Build that's being performed.
* @param envs * @param envs
* Partially built environment variable map. Implementation of this method is expected to * Partially built environment variable map. Implementation of this method is expected to
* add additional variables here. Never null. * add additional variables here.
* @param listener * @param listener
* Connected to the build console. Can be used to report errors. Never null. * Connected to the build console. Can be used to report errors.
*/ */
public void buildEnvironmentFor(Run r, EnvVars envs, TaskListener listener) throws IOException, InterruptedException {} public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException {}
/** /**
* Contributes environment variables used for a job. * Contributes environment variables used for a job.
...@@ -103,12 +104,12 @@ public abstract class EnvironmentContributor implements ExtensionPoint { ...@@ -103,12 +104,12 @@ public abstract class EnvironmentContributor implements ExtensionPoint {
* Job for which some activities are launched. * Job for which some activities are launched.
* @param envs * @param envs
* Partially built environment variable map. Implementation of this method is expected to * Partially built environment variable map. Implementation of this method is expected to
* add additional variables here. Never null. * add additional variables here.
* @param listener * @param listener
* Connected to the build console. Can be used to report errors. Never null. * Connected to the build console. Can be used to report errors.
* @since 1.527 * @since 1.527
*/ */
public void buildEnvironmentFor(Job j, EnvVars envs, TaskListener listener) throws IOException, InterruptedException {} public void buildEnvironmentFor(@Nonnull Job j, @Nonnull EnvVars envs, @Nonnull TaskListener listener) throws IOException, InterruptedException {}
/** /**
* Returns all the registered {@link EnvironmentContributor}s. * Returns all the registered {@link EnvironmentContributor}s.
......
...@@ -96,6 +96,8 @@ import java.io.*; ...@@ -96,6 +96,8 @@ import java.io.*;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.*; import java.util.*;
import java.util.List; import java.util.List;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import static javax.servlet.http.HttpServletResponse.*; import static javax.servlet.http.HttpServletResponse.*;
import jenkins.model.lazy.LazyBuildMixIn; import jenkins.model.lazy.LazyBuildMixIn;
...@@ -356,7 +358,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R ...@@ -356,7 +358,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
* Node to eventually run a process on. The implementation must cope with this parameter being null * Node to eventually run a process on. The implementation must cope with this parameter being null
* (in which case none of the node specific properties would be reflected in the resulting override.) * (in which case none of the node specific properties would be reflected in the resulting override.)
*/ */
public EnvVars getEnvironment(Node node, TaskListener listener) throws IOException, InterruptedException { public @Nonnull EnvVars getEnvironment(@CheckForNull Node node, @Nonnull TaskListener listener) throws IOException, InterruptedException {
EnvVars env; EnvVars env;
if (node!=null) { if (node!=null) {
......
...@@ -2206,10 +2206,10 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run ...@@ -2206,10 +2206,10 @@ public abstract class Run <JobT extends Job<JobT,RunT>,RunT extends Run<JobT,Run
* Unlike earlier {@link #getEnvVars()}, this map contains the whole environment, * Unlike earlier {@link #getEnvVars()}, this map contains the whole environment,
* not just the overrides, so one can introspect values to change its behavior. * not just the overrides, so one can introspect values to change its behavior.
* *
* @return the map with the environmental variables. Never <code>null</code>. * @return the map with the environmental variables.
* @since 1.305 * @since 1.305
*/ */
public EnvVars getEnvironment(TaskListener listener) throws IOException, InterruptedException { public @Nonnull EnvVars getEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException {
Computer c = Computer.currentComputer(); Computer c = Computer.currentComputer();
Node n = c==null ? null : c.getNode(); Node n = c==null ? null : c.getNode();
......
...@@ -39,6 +39,7 @@ import hudson.model.BuildListener; ...@@ -39,6 +39,7 @@ import hudson.model.BuildListener;
import hudson.model.Environment; import hudson.model.Environment;
import jenkins.model.Jenkins; import jenkins.model.Jenkins;
import hudson.model.Node; import hudson.model.Node;
import hudson.model.Queue;
import hudson.model.Queue.Task; import hudson.model.Queue.Task;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerRequest;
...@@ -47,6 +48,7 @@ import java.io.File; ...@@ -47,6 +48,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.annotation.Nonnull;
/** /**
* Extensible property of {@link Node}. * Extensible property of {@link Node}.
...@@ -161,7 +163,7 @@ public abstract class NodeProperty<N extends Node> implements ReconfigurableDesc ...@@ -161,7 +163,7 @@ public abstract class NodeProperty<N extends Node> implements ReconfigurableDesc
* *
* @since 1.489 * @since 1.489
*/ */
public void buildEnvVars(EnvVars env, TaskListener listener) throws IOException,InterruptedException { public void buildEnvVars(@Nonnull EnvVars env, @Nonnull TaskListener listener) throws IOException,InterruptedException {
// default is no-op // default is no-op
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册