diff --git a/.gitignore b/.gitignore index 5c8b1b7ac8b0..2e01e8556bcb 100644 --- a/.gitignore +++ b/.gitignore @@ -54,3 +54,4 @@ push-build.sh war/node_modules/ war/yarn-error.log .java-version +.checkstyle diff --git a/core/src/main/java/hudson/AboutJenkins.java b/core/src/main/java/hudson/AboutJenkins.java index 8592c5c3f499..9876f5701b47 100644 --- a/core/src/main/java/hudson/AboutJenkins.java +++ b/core/src/main/java/hudson/AboutJenkins.java @@ -4,7 +4,7 @@ import hudson.security.Permission; import java.net.URL; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import org.jenkinsci.Symbol; import org.kohsuke.accmod.Restricted; @@ -41,13 +41,13 @@ public URL getLicensesURL() { return AboutJenkins.class.getResource("/META-INF/licenses.xml"); } - @Nonnull + @NonNull @Override public Permission getRequiredPermission() { return Jenkins.READ; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.STATUS; diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java index e3af9fc07cc0..0169f79eb0c8 100644 --- a/core/src/main/java/hudson/ClassicPluginStrategy.java +++ b/core/src/main/java/hudson/ClassicPluginStrategy.java @@ -54,7 +54,7 @@ import org.apache.tools.zip.ZipOutputStream; import org.jenkinsci.bytecode.Transformer; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.Closeable; import java.io.File; import java.io.FileNotFoundException; @@ -273,7 +273,7 @@ private void fix(Attributes atts, List optionalDepende * @see DetachedPluginsUtil#getImpliedDependencies(String, String) */ @Deprecated // since TODO - @Nonnull + @NonNull public static List getImpliedDependencies(String pluginName, String jenkinsVersion) { return DetachedPluginsUtil.getImpliedDependencies(pluginName, jenkinsVersion); } diff --git a/core/src/main/java/hudson/DescriptorExtensionList.java b/core/src/main/java/hudson/DescriptorExtensionList.java index acc12df9b8cf..ec0b76337c94 100644 --- a/core/src/main/java/hudson/DescriptorExtensionList.java +++ b/core/src/main/java/hudson/DescriptorExtensionList.java @@ -45,8 +45,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.concurrent.CopyOnWriteArrayList; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import net.sf.json.JSONException; import org.kohsuke.stapler.Stapler; @@ -158,7 +158,7 @@ public T newInstanceFromRadioList(JSONObject config) throws FormException { * @throws FormException Data submission error */ @CheckForNull - public T newInstanceFromRadioList(@Nonnull JSONObject parent, @Nonnull String name) throws FormException { + public T newInstanceFromRadioList(@NonNull JSONObject parent, @NonNull String name) throws FormException { try { return newInstanceFromRadioList(parent.getJSONObject(name)); } catch (JSONException ex) { diff --git a/core/src/main/java/hudson/EnvVars.java b/core/src/main/java/hudson/EnvVars.java index c1e22c05238f..d3945a561a58 100644 --- a/core/src/main/java/hudson/EnvVars.java +++ b/core/src/main/java/hudson/EnvVars.java @@ -43,8 +43,8 @@ import java.util.TreeSet; import java.util.UUID; import java.util.logging.Logger; -import javax.annotation.Nonnull; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Environment variables. @@ -101,14 +101,14 @@ public class EnvVars extends TreeMap { * @since 2.144 * @param platform the platform to set. */ - public void setPlatform(@Nonnull Platform platform) { + public void setPlatform(@NonNull Platform platform) { this.platform = platform; } public EnvVars() { super(CaseInsensitiveComparator.INSTANCE); } - public EnvVars(@Nonnull Map m) { + public EnvVars(@NonNull Map m) { this(); putAll(m); @@ -121,7 +121,7 @@ public EnvVars(@Nonnull Map m) { } @SuppressWarnings("CopyConstructorMissesField") // does not set #platform, see its Javadoc - public EnvVars(@Nonnull EnvVars m) { + public EnvVars(@NonNull EnvVars m) { // this constructor is so that in future we can get rid of the downcasting. this((Map)m); } @@ -231,15 +231,15 @@ protected Iterable getEdges(String n) { private final Comparator comparator; - @Nonnull + @NonNull private final EnvVars target; - @Nonnull + @NonNull private final Map overrides; private Map> refereeSetMap; private List orderedVariableNames; - public OverrideOrderCalculator(@Nonnull EnvVars target, @Nonnull Map overrides) { + public OverrideOrderCalculator(@NonNull EnvVars target, @NonNull Map overrides) { comparator = target.comparator(); this.target = target; this.overrides = overrides; @@ -348,7 +348,7 @@ public void scan() { * See {@link #override(String, String)}. * @return {@code this} */ - public EnvVars overrideExpandingAll(@Nonnull Map all) { + public EnvVars overrideExpandingAll(@NonNull Map all) { for (String key : new OverrideOrderCalculator(this, all).getOrderedVariableNames()) { override(key, expand(all.get(key))); } diff --git a/core/src/main/java/hudson/ExtensionList.java b/core/src/main/java/hudson/ExtensionList.java index 6cbdd051dfe6..5be5b80bc2bf 100644 --- a/core/src/main/java/hudson/ExtensionList.java +++ b/core/src/main/java/hudson/ExtensionList.java @@ -45,8 +45,8 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.util.io.OnMaster; /** @@ -137,7 +137,7 @@ protected ExtensionList(Jenkins jenkins, Class extensionType, CopyOnWriteArra * Add a listener to the extension list. * @param listener The listener. */ - public void addListener(@Nonnull ExtensionListListener listener) { + public void addListener(@NonNull ExtensionListListener listener) { listeners.add(listener); } @@ -145,7 +145,7 @@ public void addListener(@Nonnull ExtensionListListener listener) { * Looks for the extension instance of the given type (subclasses excluded), * or return null. */ - public @CheckForNull U get(@Nonnull Class type) { + public @CheckForNull U get(@NonNull Class type) { for (T ext : this) if(ext.getClass()==type) return type.cast(ext); @@ -158,7 +158,7 @@ public void addListener(@Nonnull ExtensionListListener listener) { * * Meant to simplify call inside @Extension annotated class to retrieve their own instance. */ - public @Nonnull U getInstance(@Nonnull Class type) throws IllegalStateException { + public @NonNull U getInstance(@NonNull Class type) throws IllegalStateException { for (T ext : this) if(ext.getClass()==type) return type.cast(ext); @@ -167,7 +167,7 @@ public void addListener(@Nonnull ExtensionListListener listener) { } @Override - public @Nonnull Iterator iterator() { + public @NonNull Iterator iterator() { // we need to intercept mutation, so for now don't allow Iterator.remove return new AdaptedIterator,T>(Iterators.readOnly(ensureLoaded().iterator())) { protected T adapt(ExtensionComponent item) { @@ -429,7 +429,7 @@ public static ExtensionList create(Jenkins jenkins, Class type) { * @return some list * @since 1.572 */ - public static @Nonnull ExtensionList lookup(Class type) { + public static @NonNull ExtensionList lookup(Class type) { Jenkins j = Jenkins.getInstanceOrNull(); return j == null ? create((Jenkins) null, type) : j.getExtensionList(type); } @@ -445,7 +445,7 @@ public static ExtensionList create(Jenkins jenkins, Class type) { * * @since 2.87 */ - public static @Nonnull U lookupSingleton(Class type) { + public static @NonNull U lookupSingleton(Class type) { ExtensionList all = lookup(type); if (all.size() != 1) { throw new IllegalStateException("Expected 1 instance of " + type.getName() + " but got " + all.size()); diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index ea1c06c7d655..5b764b83ec14 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -107,9 +107,9 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import jenkins.FilePathFilter; import jenkins.MasterToSlaveFileCallable; import jenkins.SlaveToMasterFileCallable; @@ -256,7 +256,7 @@ public final class FilePath implements SerializableOnlyOverRemoting { * To create a path that represents a remote path, pass in a {@link Channel} * that's connected to that machine. If {@code null}, that means the local file path. */ - public FilePath(@CheckForNull VirtualChannel channel, @Nonnull String remote) { + public FilePath(@CheckForNull VirtualChannel channel, @NonNull String remote) { this.channel = channel instanceof LocalChannel ? null : channel; this.remote = normalize(remote); } @@ -268,7 +268,7 @@ public FilePath(@CheckForNull VirtualChannel channel, @Nonnull String remote) { * A "local" path means a file path on the computer where the * constructor invocation happened. */ - public FilePath(@Nonnull File localPath) { + public FilePath(@NonNull File localPath) { this.channel = null; this.remote = normalize(localPath.getPath()); } @@ -278,7 +278,7 @@ public FilePath(@Nonnull File localPath) { * @param base starting point for resolution, and defines channel * @param rel a path which if relative will be resolved against base */ - public FilePath(@Nonnull FilePath base, @Nonnull String rel) { + public FilePath(@NonNull FilePath base, @NonNull String rel) { this.channel = base.channel; this.remote = normalize(resolvePathIfRelative(base, rel)); } @@ -288,7 +288,7 @@ private Object readResolve() { return this; } - private String resolvePathIfRelative(@Nonnull FilePath base, @Nonnull String rel) { + private String resolvePathIfRelative(@NonNull FilePath base, @NonNull String rel) { if(isAbsolute(rel)) return rel; if(base.isUnix()) { // shouldn't need this replace, but better safe than sorry @@ -303,7 +303,7 @@ private String resolvePathIfRelative(@Nonnull FilePath base, @Nonnull String rel /** * Is the given path name an absolute path? */ - private static boolean isAbsolute(@Nonnull String rel) { + private static boolean isAbsolute(@NonNull String rel) { return rel.startsWith("/") || DRIVE_PATTERN.matcher(rel).matches() || UNC_PATTERN.matcher(rel).matches(); } @@ -316,7 +316,7 @@ private static boolean isAbsolute(@Nonnull String rel) { * so remove them. */ @Restricted(NoExternalUse.class) - public static String normalize(@Nonnull String path) { + public static String normalize(@NonNull String path) { StringBuilder buf = new StringBuilder(); // Check for prefix designating absolute path Matcher m = ABSOLUTE_PREFIX_PATTERN.matcher(path); @@ -843,14 +843,14 @@ public Void invoke(File dir, VirtualChannel channel) throws IOException { * was considered up to date. * @since 1.299 */ - public boolean installIfNecessaryFrom(@Nonnull URL archive, @CheckForNull TaskListener listener, @Nonnull String message) throws IOException, InterruptedException { + public boolean installIfNecessaryFrom(@NonNull URL archive, @CheckForNull TaskListener listener, @NonNull String message) throws IOException, InterruptedException { if (listener == null) { listener = TaskListener.NULL; } return installIfNecessaryFrom(archive, listener, message, MAX_REDIRECTS); } - private boolean installIfNecessaryFrom(@Nonnull URL archive, @Nonnull TaskListener listener, @Nonnull String message, int maxRedirects) throws InterruptedException, IOException { + private boolean installIfNecessaryFrom(@NonNull URL archive, @NonNull TaskListener listener, @NonNull String message, int maxRedirects) throws InterruptedException, IOException { try { FilePath timestamp = this.child(".timestamp"); long lastModified = timestamp.lastModified(); @@ -1342,7 +1342,7 @@ public FilePath withSuffix(String suffix) { * @param relOrAbsolute a relative or absolute path * @return a file on the same channel */ - public @Nonnull FilePath child(String relOrAbsolute) { + public @NonNull FilePath child(String relOrAbsolute) { return new FilePath(this,relOrAbsolute); } @@ -1793,7 +1793,7 @@ public Integer invoke(File f, VirtualChannel channel) throws IOException { *

* This method returns direct children of the directory denoted by the 'this' object. */ - @Nonnull + @NonNull public List list() throws IOException, InterruptedException { return list((FileFilter)null); } @@ -1803,7 +1803,7 @@ public List list() throws IOException, InterruptedException { * * @return can be empty but never null. Doesn't contain "." and ".." */ - @Nonnull + @NonNull public List listDirectories() throws IOException, InterruptedException { return list(new DirectoryFilter()); } @@ -1824,7 +1824,7 @@ public boolean accept(File f) { * If this {@link FilePath} represents a remote path, * the filter object will be executed on the remote machine. */ - @Nonnull + @NonNull public List list(final FileFilter filter) throws IOException, InterruptedException { if (filter != null && !(filter instanceof Serializable)) { throw new IllegalArgumentException("Non-serializable filter of " + filter.getClass()); @@ -1860,7 +1860,7 @@ public List invoke(File f, VirtualChannel channel) throws IOException * @return * can be empty but always non-null. */ - @Nonnull + @NonNull public FilePath[] list(final String includes) throws IOException, InterruptedException { return list(includes, null); } @@ -1875,7 +1875,7 @@ public FilePath[] list(final String includes) throws IOException, InterruptedExc * can be empty but always non-null. * @since 1.407 */ - @Nonnull + @NonNull public FilePath[] list(final String includes, final String excludes) throws IOException, InterruptedException { return list(includes, excludes, true); } @@ -1891,7 +1891,7 @@ public FilePath[] list(final String includes, final String excludes) throws IOEx * can be empty but always non-null. * @since 1.465 */ - @Nonnull + @NonNull public FilePath[] list(final String includes, final String excludes, final boolean defaultExcludes) throws IOException, InterruptedException { return act(new ListGlob(includes, excludes, defaultExcludes)); } @@ -1923,7 +1923,7 @@ public FilePath[] invoke(File f, VirtualChannel channel) throws IOException { * @return * A set of relative file names from the base directory. */ - @Nonnull + @NonNull private static String[] glob(File dir, String includes, String excludes, boolean defaultExcludes) throws IOException { if(isAbsolute(includes)) throw new IOException("Expecting Ant GLOB pattern, but saw '"+includes+"'. See http://ant.apache.org/manual/Types/fileset.html for syntax"); @@ -2363,7 +2363,7 @@ public int copyRecursiveTo(final DirScanner scanner, final FilePath target, fina * @return the number of files copied * @since 2.196 */ - public int copyRecursiveTo(final DirScanner scanner, final FilePath target, final String description, @Nonnull TarCompression compression) throws IOException, InterruptedException { + public int copyRecursiveTo(final DirScanner scanner, final FilePath target, final String description, @NonNull TarCompression compression) throws IOException, InterruptedException { if(this.channel==target.channel) { // local to local copy. return act(new CopyRecursiveLocal(target, scanner)); @@ -2490,7 +2490,7 @@ private class ReadToTar extends SecureFileCallable { private final String description; private final TarCompression compression; - ReadToTar(Pipe pipe, String description, @Nonnull TarCompression compression) { + ReadToTar(Pipe pipe, String description, @NonNull TarCompression compression) { this.pipe = pipe; this.description = description; this.compression = compression; @@ -2508,7 +2508,7 @@ private class WriteToTar extends SecureFileCallable { private final DirScanner scanner; private final Pipe pipe; private final TarCompression compression; - WriteToTar(DirScanner scanner, Pipe pipe, @Nonnull TarCompression compression) { + WriteToTar(DirScanner scanner, Pipe pipe, @NonNull TarCompression compression) { this.scanner = scanner; this.pipe = pipe; this.compression = compression; @@ -2524,7 +2524,7 @@ private class CopyRecursiveRemoteToLocal extends SecureFileCallable { private final Pipe pipe; private final DirScanner scanner; private final TarCompression compression; - CopyRecursiveRemoteToLocal(Pipe pipe, DirScanner scanner, @Nonnull TarCompression compression) { + CopyRecursiveRemoteToLocal(Pipe pipe, DirScanner scanner, @NonNull TarCompression compression) { this.pipe = pipe; this.scanner = scanner; this.compression = compression; @@ -2629,7 +2629,7 @@ public Launcher createLauncher(TaskListener listener) throws IOException, Interr } private static final class IsUnix extends MasterToSlaveCallable { - @Nonnull + @NonNull public Boolean call() throws IOException { return File.pathSeparatorChar==':'; } @@ -3165,10 +3165,10 @@ public ExplicitlySpecifiedDirScanner(Map files) { /** * Channel to the current instance. */ - @Nonnull + @NonNull public static final LocalChannel localChannel = new LocalChannel(threadPoolForRemoting); - private @Nonnull SoloFilePathFilter filterNonNull() { + private @NonNull SoloFilePathFilter filterNonNull() { return filter!=null ? filter : UNRESTRICTED; } @@ -3275,7 +3275,7 @@ private File mkdirsE(File dir) throws IOException { * TODO un-restrict it in a weekly after the patch */ @Restricted(NoExternalUse.class) - public boolean isDescendant(@Nonnull String potentialChildRelativePath) throws IOException, InterruptedException { + public boolean isDescendant(@NonNull String potentialChildRelativePath) throws IOException, InterruptedException { return act(new IsDescendant(potentialChildRelativePath)); } @@ -3283,12 +3283,12 @@ private static class IsDescendant extends SecureFileCallable { private static final long serialVersionUID = 1L; private String potentialChildRelativePath; - private IsDescendant(@Nonnull String potentialChildRelativePath){ + private IsDescendant(@NonNull String potentialChildRelativePath){ this.potentialChildRelativePath = potentialChildRelativePath; } @Override - public Boolean invoke(@Nonnull File parentFile, @Nonnull VirtualChannel channel) throws IOException, InterruptedException { + public Boolean invoke(@NonNull File parentFile, @NonNull VirtualChannel channel) throws IOException, InterruptedException { if (new File(potentialChildRelativePath).isAbsolute()) { throw new IllegalArgumentException("Only a relative path is supported, the given path is absolute: " + potentialChildRelativePath); } @@ -3363,7 +3363,7 @@ public Boolean invoke(@Nonnull File parentFile, @Nonnull VirtualChannel channel) return current; } - private @Nonnull Path windowsToRealPath(@Nonnull Path path) throws IOException { + private @NonNull Path windowsToRealPath(@NonNull Path path) throws IOException { try { return path.toRealPath(); } diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 353997c69f85..25d485bf1d84 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -132,7 +132,7 @@ import java.util.logging.SimpleFormatter; import java.util.regex.Pattern; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; import javax.servlet.ServletException; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; @@ -166,8 +166,8 @@ import java.util.HashSet; import java.util.Set; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.apache.commons.io.IOUtils; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -1628,7 +1628,7 @@ public static T defaulted(T value, T defaultValue) { * otherwise, the method returns a default * "No exception details" string. */ - public static @Nonnull String printThrowable(@CheckForNull Throwable t) { + public static @NonNull String printThrowable(@CheckForNull Throwable t) { if (t == null) { return Messages.Functions_NoExceptionDetails(); } @@ -1636,7 +1636,7 @@ public static T defaulted(T value, T defaultValue) { doPrintStackTrace(s, t, null, "", new HashSet<>()); return s.toString(); } - private static void doPrintStackTrace(@Nonnull StringBuilder s, @Nonnull Throwable t, @CheckForNull Throwable higher, @Nonnull String prefix, @Nonnull Set encountered) { + private static void doPrintStackTrace(@NonNull StringBuilder s, @NonNull Throwable t, @CheckForNull Throwable higher, @NonNull String prefix, @NonNull Set encountered) { if (!encountered.add(t)) { s.append("\n"); return; @@ -1689,7 +1689,7 @@ private static void doPrintStackTrace(@Nonnull StringBuilder s, @Nonnull Throwab * @param pw the log * @since 2.43 */ - public static void printStackTrace(@CheckForNull Throwable t, @Nonnull PrintWriter pw) { + public static void printStackTrace(@CheckForNull Throwable t, @NonNull PrintWriter pw) { pw.println(printThrowable(t).trim()); } @@ -1699,7 +1699,7 @@ public static void printStackTrace(@CheckForNull Throwable t, @Nonnull PrintWrit * @param ps the log * @since 2.43 */ - public static void printStackTrace(@CheckForNull Throwable t, @Nonnull PrintStream ps) { + public static void printStackTrace(@CheckForNull Throwable t, @NonNull PrintStream ps) { ps.println(printThrowable(t).trim()); } diff --git a/core/src/main/java/hudson/Launcher.java b/core/src/main/java/hudson/Launcher.java index d2007e14b168..850ead6bec94 100644 --- a/core/src/main/java/hudson/Launcher.java +++ b/core/src/main/java/hudson/Launcher.java @@ -43,7 +43,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.io.BufferedOutputStream; import java.io.File; import java.io.IOException; @@ -60,7 +60,7 @@ import static org.apache.commons.io.output.NullOutputStream.NULL_OUTPUT_STREAM; import hudson.Proc.ProcWithJenkins23271Patch; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Starts a process. @@ -84,13 +84,13 @@ */ public abstract class Launcher { - @Nonnull + @NonNull protected final TaskListener listener; @CheckForNull protected final VirtualChannel channel; - public Launcher(@Nonnull TaskListener listener, @CheckForNull VirtualChannel channel) { + public Launcher(@NonNull TaskListener listener, @CheckForNull VirtualChannel channel) { this.listener = listener; this.channel = channel; } @@ -99,7 +99,7 @@ public Launcher(@Nonnull TaskListener listener, @CheckForNull VirtualChannel cha * Constructor for a decorator. * @param launcher Launcher to be decorated */ - protected Launcher(@Nonnull Launcher launcher) { + protected Launcher(@NonNull Launcher launcher) { this(launcher.listener, launcher.channel); } @@ -122,7 +122,7 @@ public VirtualChannel getChannel() { * * @return Task listener */ - @Nonnull + @NonNull public TaskListener getListener() { return listener; } @@ -265,11 +265,11 @@ public ProcStarter pwd(@CheckForNull FilePath workDir) { return this; } - public ProcStarter pwd(@Nonnull File workDir) { + public ProcStarter pwd(@NonNull File workDir) { return pwd(new FilePath(workDir)); } - public ProcStarter pwd(@Nonnull String workDir) { + public ProcStarter pwd(@NonNull String workDir) { return pwd(new File(workDir)); } @@ -297,7 +297,7 @@ public ProcStarter stdout(@CheckForNull OutputStream out) { * @param out Task listener (must be safely remotable) * @return {@code this} */ - public ProcStarter stdout(@Nonnull TaskListener out) { + public ProcStarter stdout(@NonNull TaskListener out) { stdout = out.getLogger(); stdoutListener = out; return this; @@ -338,7 +338,7 @@ public OutputStream stderr() { * * @return {@code this} */ - @Nonnull + @NonNull public ProcStarter stdin(@CheckForNull InputStream in) { this.stdin = in; return this; @@ -365,7 +365,7 @@ public InputStream stdin() { * @param overrides Environment variables to be overridden * @return {@code this} */ - public ProcStarter envs(@Nonnull Map overrides) { + public ProcStarter envs(@NonNull Map overrides) { this.envs = Util.mapToEnv(overrides); return this; } @@ -394,7 +394,7 @@ public ProcStarter envs(@CheckForNull String... overrides) { * * @return If initialized, returns a copy of internal envs array. Otherwise - a new empty array. */ - @Nonnull + @NonNull public String[] envs() { return envs != null ? envs.clone() : MemoryReductionUtil.EMPTY_STRING_ARRAY; } @@ -492,7 +492,7 @@ public int join() throws IOException, InterruptedException { /** * Copies a {@link ProcStarter}. */ - @Nonnull + @NonNull public ProcStarter copy() { ProcStarter rhs = new ProcStarter().cmds(commands).pwd(pwd).masks(masks).stdin(stdin).stdout(stdout).stderr(stderr).envs(envs).quiet(quiet); rhs.stdoutListener = stdoutListener; @@ -507,7 +507,7 @@ public ProcStarter copy() { * Launches a process by using a {@linkplain ProcStarter builder-pattern} to configure * the parameters. */ - @Nonnull + @NonNull public final ProcStarter launch() { return new ProcStarter(); } @@ -699,7 +699,7 @@ public Proc launch(String[] cmd, boolean[] mask, String[] env, InputStream in, O /** * Primarily invoked from {@link ProcStarter#start()} to start a process with a specific launcher. */ - public abstract Proc launch(@Nonnull ProcStarter starter) throws IOException; + public abstract Proc launch(@NonNull ProcStarter starter) throws IOException; /** * Launches a specified process and connects its input/output to a {@link Channel}, then @@ -720,8 +720,8 @@ public Proc launch(String[] cmd, boolean[] mask, String[] env, InputStream in, O * is inherited (if this is going to be launched from an agent, that * becomes the "current" process), these variables will be also set. */ - public abstract Channel launchChannel(@Nonnull String[] cmd, @Nonnull OutputStream out, - @CheckForNull FilePath workDir, @Nonnull Map envVars) throws IOException, InterruptedException; + public abstract Channel launchChannel(@NonNull String[] cmd, @NonNull OutputStream out, + @CheckForNull FilePath workDir, @NonNull Map envVars) throws IOException, InterruptedException; /** * Returns true if this {@link Launcher} is going to launch on Unix. @@ -738,7 +738,7 @@ public boolean isUnix() { /** * Prints out the command line to the listener so that users know what we are doing. */ - protected final void printCommandLine(@Nonnull String[] cmd, @CheckForNull FilePath workDir) { + protected final void printCommandLine(@NonNull String[] cmd, @CheckForNull FilePath workDir) { StringBuilder buf = new StringBuilder(); if (workDir != null) { buf.append('['); @@ -772,7 +772,7 @@ protected final void printCommandLine(@Nonnull String[] cmd, @CheckForNull FileP * remain unmasked ({@code false}). * @param workDir The work dir. */ - protected final void maskedPrintCommandLine(@Nonnull List cmd, @CheckForNull boolean[] mask, @CheckForNull FilePath workDir) { + protected final void maskedPrintCommandLine(@NonNull List cmd, @CheckForNull boolean[] mask, @CheckForNull FilePath workDir) { if(mask==null) { printCommandLine(cmd.toArray(new String[0]),workDir); return; @@ -790,7 +790,7 @@ protected final void maskedPrintCommandLine(@Nonnull List cmd, @CheckFor printCommandLine(masked, workDir); } - protected final void maskedPrintCommandLine(@Nonnull String[] cmd, @Nonnull boolean[] mask, @CheckForNull FilePath workDir) { + protected final void maskedPrintCommandLine(@NonNull String[] cmd, @NonNull boolean[] mask, @CheckForNull FilePath workDir) { maskedPrintCommandLine(Arrays.asList(cmd),mask,workDir); } @@ -800,8 +800,8 @@ protected final void maskedPrintCommandLine(@Nonnull String[] cmd, @Nonnull bool * @param node Node for which this launcher is created. * @return Decorated instance of the Launcher. */ - @Nonnull - public final Launcher decorateFor(@Nonnull Node node) { + @NonNull + public final Launcher decorateFor(@NonNull Node node) { Launcher l = this; for (LauncherDecorator d : LauncherDecorator.all()) l = d.decorate(l,node); @@ -815,7 +815,7 @@ public final Launcher decorateFor(@Nonnull Node node) { * @param prefix Prefixes to be appended * @since 1.299 */ - @Nonnull + @NonNull public final Launcher decorateByPrefix(final String... prefix) { final Launcher outer = this; return new Launcher(outer) { @@ -844,14 +844,14 @@ public void kill(Map modelEnvVars) throws IOException, Interrupt outer.kill(modelEnvVars); } - private String[] prefix(@Nonnull String[] args) { + private String[] prefix(@NonNull String[] args) { String[] newArgs = new String[args.length+prefix.length]; System.arraycopy(prefix,0,newArgs,0,prefix.length); System.arraycopy(args,0,newArgs,prefix.length,args.length); return newArgs; } - private boolean[] prefix(@Nonnull boolean[] args) { + private boolean[] prefix(@NonNull boolean[] args) { boolean[] newArgs = new boolean[args.length+prefix.length]; System.arraycopy(args,0,newArgs,prefix.length,args.length); return newArgs; @@ -868,8 +868,8 @@ private boolean[] prefix(@Nonnull boolean[] args) { * * @since 1.489 */ - @Nonnull - public final Launcher decorateByEnv(@Nonnull EnvVars _env) { + @NonNull + public final Launcher decorateByEnv(@NonNull EnvVars _env) { final EnvVars env = new EnvVars(_env); final Launcher outer = this; return new Launcher(outer) { @@ -908,7 +908,7 @@ public void kill(Map modelEnvVars) throws IOException, Interrupt * {@link Launcher} that launches process locally. */ public static class LocalLauncher extends Launcher { - public LocalLauncher(@Nonnull TaskListener listener) { + public LocalLauncher(@NonNull TaskListener listener) { this(listener, FilePath.localChannel); } @@ -1003,7 +1003,7 @@ public synchronized void close() throws IOException { @Restricted(NoExternalUse.class) public static class DummyLauncher extends Launcher { - public DummyLauncher(@Nonnull TaskListener listener) { + public DummyLauncher(@NonNull TaskListener listener) { super(listener, null); } @@ -1030,13 +1030,13 @@ public void kill(Map modelEnvVars) throws IOException, Interrupt public static class RemoteLauncher extends Launcher { private final boolean isUnix; - public RemoteLauncher(@Nonnull TaskListener listener, @Nonnull VirtualChannel channel, boolean isUnix) { + public RemoteLauncher(@NonNull TaskListener listener, @NonNull VirtualChannel channel, boolean isUnix) { super(listener, channel); this.isUnix = isUnix; } @Override - @Nonnull + @NonNull public VirtualChannel getChannel() { VirtualChannel vc = super.getChannel(); if (vc == null) { @@ -1179,7 +1179,7 @@ public static class DecoratedLauncher extends Launcher { private final Launcher inner; - public DecoratedLauncher(@Nonnull Launcher inner) { + public DecoratedLauncher(@NonNull Launcher inner) { super(inner); this.inner = inner; } @@ -1241,7 +1241,7 @@ public Proc launch(String[] cmd, String[] env, InputStream in, OutputStream out, * Gets nested launcher. * @return Inner launcher */ - @Nonnull + @NonNull public Launcher getInner() { return inner; } @@ -1262,28 +1262,28 @@ public interface RemoteProcess { void kill() throws IOException, InterruptedException; boolean isAlive() throws IOException, InterruptedException; - @Nonnull + @NonNull IOTriplet getIOtriplet(); } private static class RemoteLaunchCallable extends MasterToSlaveCallable { - private final @Nonnull List cmd; + private final @NonNull List cmd; private final @CheckForNull boolean[] masks; private final @CheckForNull String[] env; private final @CheckForNull InputStream in; private final @CheckForNull OutputStream out; private final @CheckForNull OutputStream err; private final @CheckForNull String workDir; - private final @Nonnull TaskListener listener; + private final @NonNull TaskListener listener; private final @CheckForNull TaskListener stdoutListener; private final boolean reverseStdin, reverseStdout, reverseStderr; private final boolean quiet; - RemoteLaunchCallable(@Nonnull List cmd, @CheckForNull boolean[] masks, @CheckForNull String[] env, + RemoteLaunchCallable(@NonNull List cmd, @CheckForNull boolean[] masks, @CheckForNull String[] env, @CheckForNull InputStream in, boolean reverseStdin, @CheckForNull OutputStream out, boolean reverseStdout, @CheckForNull OutputStream err, boolean reverseStderr, - boolean quiet, @CheckForNull String workDir, @Nonnull TaskListener listener, @CheckForNull TaskListener stdoutListener) { + boolean quiet, @CheckForNull String workDir, @NonNull TaskListener listener, @CheckForNull TaskListener stdoutListener) { this.cmd = new ArrayList<>(cmd); this.masks = masks; this.env = env; @@ -1355,19 +1355,19 @@ public IOTriplet getIOtriplet() { } private static class RemoteChannelLaunchCallable extends MasterToSlaveCallable { - @Nonnull + @NonNull private final String[] cmd; - @Nonnull + @NonNull private final Pipe out; @CheckForNull private final String workDir; - @Nonnull + @NonNull private final OutputStream err; - @Nonnull + @NonNull private final Map envOverrides; - public RemoteChannelLaunchCallable(@Nonnull String[] cmd, @Nonnull Pipe out, @Nonnull OutputStream err, - @CheckForNull String workDir, @Nonnull Map envOverrides) { + public RemoteChannelLaunchCallable(@NonNull String[] cmd, @NonNull Pipe out, @NonNull OutputStream err, + @CheckForNull String workDir, @NonNull Map envOverrides) { this.cmd = cmd; this.out = out; this.err = new RemoteOutputStream(err); @@ -1413,7 +1413,7 @@ private static EnvVars inherit(@CheckForNull String[] env) { /** * Expands the list of environment variables by inheriting current env variables. */ - private static EnvVars inherit(@Nonnull Map overrides) { + private static EnvVars inherit(@NonNull Map overrides) { EnvVars m = new EnvVars(EnvVars.masterEnvVars); m.overrideExpandingAll(overrides); return m; diff --git a/core/src/main/java/hudson/LauncherDecorator.java b/core/src/main/java/hudson/LauncherDecorator.java index b73beb4e21cc..372f8200b9ef 100644 --- a/core/src/main/java/hudson/LauncherDecorator.java +++ b/core/src/main/java/hudson/LauncherDecorator.java @@ -6,7 +6,7 @@ import hudson.model.Executor; import hudson.model.TaskListener; import hudson.tasks.BuildWrapper; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Decorates {@link Launcher} so that one can intercept executions of commands @@ -42,8 +42,8 @@ public abstract class LauncherDecorator implements ExtensionPoint { * @see Launcher#decorateFor(Node) * @see Launcher#decorateByPrefix(String[]) */ - @Nonnull - public abstract Launcher decorate(@Nonnull Launcher launcher, @Nonnull Node node); + @NonNull + public abstract Launcher decorate(@NonNull Launcher launcher, @NonNull Node node); /** * Returns all the registered {@link LauncherDecorator}s. diff --git a/core/src/main/java/hudson/LocalPluginManager.java b/core/src/main/java/hudson/LocalPluginManager.java index fbc4cd5d4c50..4bfccf9e40a8 100644 --- a/core/src/main/java/hudson/LocalPluginManager.java +++ b/core/src/main/java/hudson/LocalPluginManager.java @@ -27,8 +27,8 @@ import jenkins.util.SystemProperties; import jenkins.model.Jenkins; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletContext; import java.io.File; import java.util.Collection; @@ -46,7 +46,7 @@ public class LocalPluginManager extends PluginManager { * @param context Servlet context. Provided for compatibility as {@code Jenkins.get().servletContext} should be used. * @param rootDir Jenkins home directory. */ - public LocalPluginManager(@CheckForNull ServletContext context, @Nonnull File rootDir) { + public LocalPluginManager(@CheckForNull ServletContext context, @NonNull File rootDir) { super(context, new File(rootDir,"plugins")); } @@ -54,7 +54,7 @@ public LocalPluginManager(@CheckForNull ServletContext context, @Nonnull File ro * Creates a new LocalPluginManager * @param jenkins Jenkins instance that will use the plugin manager. */ - public LocalPluginManager(@Nonnull Jenkins jenkins) { + public LocalPluginManager(@NonNull Jenkins jenkins) { this(jenkins.servletContext, jenkins.getRootDir()); } @@ -62,7 +62,7 @@ public LocalPluginManager(@Nonnull Jenkins jenkins) { * Creates a new LocalPluginManager * @param rootDir Jenkins home directory. */ - public LocalPluginManager(@Nonnull File rootDir) { + public LocalPluginManager(@NonNull File rootDir) { this(null, rootDir); } diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 9b6a987a8660..c7b16e4f1f2c 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -105,8 +105,8 @@ import org.xml.sax.SAXException; import org.xml.sax.helpers.DefaultHandler; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.xml.parsers.ParserConfigurationException; @@ -210,29 +210,29 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas private enum PMConstructor { JENKINS { @Override - @Nonnull - PluginManager doCreate(@Nonnull Class klass, - @Nonnull Jenkins jenkins) throws ReflectiveOperationException { + @NonNull + PluginManager doCreate(@NonNull Class klass, + @NonNull Jenkins jenkins) throws ReflectiveOperationException { return klass.getConstructor(Jenkins.class).newInstance(jenkins); } }, SC_FILE { @Override - @Nonnull PluginManager doCreate(@Nonnull Class klass, - @Nonnull Jenkins jenkins) throws ReflectiveOperationException { + @NonNull PluginManager doCreate(@NonNull Class klass, + @NonNull Jenkins jenkins) throws ReflectiveOperationException { return klass.getConstructor(ServletContext.class, File.class).newInstance(jenkins.servletContext, jenkins.getRootDir()); } }, FILE { @Override - @Nonnull PluginManager doCreate(@Nonnull Class klass, - @Nonnull Jenkins jenkins) throws ReflectiveOperationException { + @NonNull PluginManager doCreate(@NonNull Class klass, + @NonNull Jenkins jenkins) throws ReflectiveOperationException { return klass.getConstructor(File.class).newInstance(jenkins.getRootDir()); } }; - final @CheckForNull PluginManager create(@Nonnull Class klass, - @Nonnull Jenkins jenkins) throws ReflectiveOperationException { + final @CheckForNull PluginManager create(@NonNull Class klass, + @NonNull Jenkins jenkins) throws ReflectiveOperationException { try { return doCreate(klass, jenkins); } catch(NoSuchMethodException e) { @@ -241,8 +241,8 @@ PluginManager doCreate(@Nonnull Class klass, } } - abstract @Nonnull PluginManager doCreate(@Nonnull Class klass, - @Nonnull Jenkins jenkins) throws ReflectiveOperationException; + abstract @NonNull PluginManager doCreate(@NonNull Class klass, + @NonNull Jenkins jenkins) throws ReflectiveOperationException; } /** @@ -252,7 +252,7 @@ PluginManager doCreate(@Nonnull Class klass, * @return Plugin manager to use. If no custom class is configured or in case of any error, the default * {@link LocalPluginManager} is returned. */ - public static @Nonnull PluginManager createDefault(@Nonnull Jenkins jenkins) { + public static @NonNull PluginManager createDefault(@NonNull Jenkins jenkins) { String pmClassName = SystemProperties.getString(CUSTOM_PLUGIN_MANAGER); if (!StringUtils.isBlank(pmClassName)) { LOGGER.log(FINE, String.format("Use of custom plugin manager [%s] requested.", pmClassName)); @@ -625,13 +625,13 @@ void considerDetachedPlugin(String shortName) { } } - protected @Nonnull Set loadPluginsFromWar(@Nonnull String fromPath) { + protected @NonNull Set loadPluginsFromWar(@NonNull String fromPath) { return loadPluginsFromWar(fromPath, null); } //TODO: Consider refactoring in order to avoid DMI_COLLECTION_OF_URLS @SuppressFBWarnings(value = "DMI_COLLECTION_OF_URLS", justification = "Plugin loading happens only once on Jenkins startup") - protected @Nonnull Set loadPluginsFromWar(@Nonnull String fromPath, @CheckForNull FilenameFilter filter) { + protected @NonNull Set loadPluginsFromWar(@NonNull String fromPath, @CheckForNull FilenameFilter filter) { Set names = new HashSet(); ServletContext context = Jenkins.get().servletContext; @@ -820,12 +820,12 @@ public boolean accept(File dir, String name) { } } - private String normalisePluginName(@Nonnull String name) { + private String normalisePluginName(@NonNull String name) { // Normalise the name by stripping off the file extension (if present)... return name.replace(".jpi", "").replace(".hpi", ""); } - private @CheckForNull VersionNumber getPluginVersion(@Nonnull File dir, @Nonnull String pluginId) { + private @CheckForNull VersionNumber getPluginVersion(@NonNull File dir, @NonNull String pluginId) { VersionNumber version = getPluginVersion(new File(dir, pluginId + ".jpi")); if (version == null) { version = getPluginVersion(new File(dir, pluginId + ".hpi")); @@ -833,7 +833,7 @@ private String normalisePluginName(@Nonnull String name) { return version; } - private @CheckForNull VersionNumber getPluginVersion(@Nonnull File pluginFile) { + private @CheckForNull VersionNumber getPluginVersion(@NonNull File pluginFile) { if (!pluginFile.exists()) { return null; } @@ -844,7 +844,7 @@ private String normalisePluginName(@Nonnull String name) { } } - private @CheckForNull VersionNumber getPluginVersion(@Nonnull URL pluginURL) { + private @CheckForNull VersionNumber getPluginVersion(@NonNull URL pluginURL) { Manifest manifest = parsePluginManifest(pluginURL); if (manifest == null) { return null; @@ -1103,8 +1103,8 @@ protected void copyBundledPlugin(URL src, String fileName) throws IOException { * @return Input stream, which allows to retrieve manifest. This stream must be closed outside * @throws IOException Operation error */ - @Nonnull - /*package*/ static InputStream getBundledJpiManifestStream(@Nonnull URL url) throws IOException { + @NonNull + /*package*/ static InputStream getBundledJpiManifestStream(@NonNull URL url) throws IOException { URLConnection uc = url.openConnection(); InputStream in = null; // Magic, which allows to avoid using stream generated for JarURLConnection. @@ -1143,8 +1143,8 @@ protected void copyBundledPlugin(URL src, String fileName) throws IOException { * @return Modification date * @throws IOException Operation error */ - @Nonnull - /*package*/ static long getModificationDate(@Nonnull URL url) throws IOException { + @NonNull + /*package*/ static long getModificationDate(@NonNull URL url) throws IOException { URLConnection uc = url.openConnection(); // It prevents file descriptor leak if the URL references a file within JAR @@ -1493,11 +1493,11 @@ public HttpResponse doInstallPlugins(StaplerRequest req) throws IOException { * @since 2.0 */ @Restricted(NoExternalUse.class) - public List> install(@Nonnull Collection plugins, boolean dynamicLoad) { + public List> install(@NonNull Collection plugins, boolean dynamicLoad) { return install(plugins, dynamicLoad, null); } - private List> install(@Nonnull Collection plugins, boolean dynamicLoad, @CheckForNull UUID correlationId) { + private List> install(@NonNull Collection plugins, boolean dynamicLoad, @CheckForNull UUID correlationId) { List> installJobs = new ArrayList<>(); LOGGER.log(INFO, "Starting installation of a batch of {0} plugins plus their dependencies", plugins.size()); @@ -1959,7 +1959,7 @@ public MetadataCache createCache() { * @return the list of results for every plugin and their dependent plugins. * @throws IOException see {@link PluginWrapper#disable()} */ - public @Nonnull List disablePlugins(@Nonnull PluginWrapper.PluginDisableStrategy strategy, @Nonnull List plugins) throws IOException { + public @NonNull List disablePlugins(@NonNull PluginWrapper.PluginDisableStrategy strategy, @NonNull List plugins) throws IOException { // Where we store the results of each plugin disablement List results = new ArrayList<>(plugins.size()); diff --git a/core/src/main/java/hudson/PluginManagerStaplerOverride.java b/core/src/main/java/hudson/PluginManagerStaplerOverride.java index 3103ba181835..1b076df39e5f 100644 --- a/core/src/main/java/hudson/PluginManagerStaplerOverride.java +++ b/core/src/main/java/hudson/PluginManagerStaplerOverride.java @@ -1,7 +1,7 @@ package hudson; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Extension point for selectively overriding parts of the {@link PluginManager} views @@ -20,7 +20,7 @@ public abstract class PluginManagerStaplerOverride implements ExtensionPoint { * Return all implementations of this extension point * @return All implementations of this extension point */ - public static @Nonnull ExtensionList all() { + public static @NonNull ExtensionList all() { return ExtensionList.lookup(PluginManagerStaplerOverride.class); } } diff --git a/core/src/main/java/hudson/PluginStrategy.java b/core/src/main/java/hudson/PluginStrategy.java index 7804b73b2b41..0a4a6e7968b4 100644 --- a/core/src/main/java/hudson/PluginStrategy.java +++ b/core/src/main/java/hudson/PluginStrategy.java @@ -29,7 +29,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Pluggability point for how to create {@link PluginWrapper}. @@ -56,7 +56,7 @@ PluginWrapper createPluginWrapper(File archive) * Needed by {@link PluginManager#dynamicLoad} to decide whether such a plugin is already installed. * @return the {@link PluginWrapper#getShortName} */ - @Nonnull String getShortName(File archive) throws IOException; + @NonNull String getShortName(File archive) throws IOException; /** * Loads the plugin and starts it. diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 2248a769dc30..bb5e1664847f 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -51,8 +51,8 @@ import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.Closeable; import java.io.File; import java.io.IOException; @@ -227,7 +227,7 @@ public boolean hasDerivedDependencyErrors() { * Set the list of components that depend on this plugin. * @param dependents The list of components that depend on this plugin. */ - public void setDependents(@Nonnull Set dependents) { + public void setDependents(@NonNull Set dependents) { this.dependents = dependents; } @@ -235,7 +235,7 @@ public void setDependents(@Nonnull Set dependents) { * @deprecated Please use {@link #setDependents}. */ @Deprecated - public void setDependants(@Nonnull Set dependents) { + public void setDependants(@NonNull Set dependents) { setDependents(dependents); } @@ -243,7 +243,7 @@ public void setDependants(@Nonnull Set dependents) { * Set the list of components that depend optionally on this plugin. * @param optionalDependents The list of components that depend optionally on this plugin. */ - public void setOptionalDependents(@Nonnull Set optionalDependents) { + public void setOptionalDependents(@NonNull Set optionalDependents) { this.optionalDependents = optionalDependents; } @@ -251,7 +251,7 @@ public void setOptionalDependents(@Nonnull Set optionalDependents) { * @deprecated Please use {@link #setOptionalDependents}. */ @Deprecated - public void setOptionalDependants(@Nonnull Set optionalDependents) { + public void setOptionalDependants(@NonNull Set optionalDependents) { setOptionalDependents(dependents); } @@ -260,7 +260,7 @@ public void setOptionalDependants(@Nonnull Set optionalDependents) { * Note that the list will include elements of {@link #getOptionalDependents}. * @return The list of components that depend on this plugin. */ - public @Nonnull Set getDependents() { + public @NonNull Set getDependents() { if (isBundled && dependents.isEmpty()) { return CORE_ONLY_DEPENDANT; } else { @@ -272,7 +272,7 @@ public void setOptionalDependants(@Nonnull Set optionalDependents) { * @deprecated Please use {@link #getDependents}. */ @Deprecated - public @Nonnull Set getDependants() { + public @NonNull Set getDependants() { return getDependents(); } @@ -280,7 +280,7 @@ public void setOptionalDependants(@Nonnull Set optionalDependents) { * Like {@link #getDependents} but excluding optional dependencies. * @since 2.181 */ - public @Nonnull Set getMandatoryDependents() { + public @NonNull Set getMandatoryDependents() { Set s = new HashSet<>(dependents); s.removeAll(optionalDependents); return s; @@ -289,7 +289,7 @@ public void setOptionalDependants(@Nonnull Set optionalDependents) { /** * @return The list of components that depend optionally on this plugin. */ - public @Nonnull Set getOptionalDependents() { + public @NonNull Set getOptionalDependents() { return optionalDependents; } @@ -297,7 +297,7 @@ public void setOptionalDependants(@Nonnull Set optionalDependents) { * @deprecated Please use {@link #getOptionalDependents}. */ @Deprecated - public @Nonnull Set getOptionalDependants() { + public @NonNull Set getOptionalDependants() { return getOptionalDependents(); } @@ -707,7 +707,7 @@ private void disableWithoutCheck() throws IOException { * @param strategy strategy to use * @return an object representing the result of the disablement of this plugin and its dependents plugins. */ - public @Nonnull PluginDisableResult disable(@Nonnull PluginDisableStrategy strategy) { + public @NonNull PluginDisableResult disable(@NonNull PluginDisableStrategy strategy) { PluginDisableResult result = new PluginDisableResult(shortName); if (!this.isEnabled()) { @@ -955,7 +955,7 @@ private void versionDependencyError(String message, String actual, String minimu /** * Similar to {@code org.apache.maven.artifact.ArtifactUtils.isSnapshot}. */ - static boolean isSnapshot(@Nonnull String version) { + static boolean isSnapshot(@NonNull String version) { return version.contains("-SNAPSHOT") || version.matches(".+-[0-9]{8}.[0-9]{6}-[0-9]+"); } diff --git a/core/src/main/java/hudson/Proc.java b/core/src/main/java/hudson/Proc.java index f387d6abcc48..ad825bb10efa 100644 --- a/core/src/main/java/hudson/Proc.java +++ b/core/src/main/java/hudson/Proc.java @@ -51,7 +51,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; diff --git a/core/src/main/java/hudson/ProxyConfiguration.java b/core/src/main/java/hudson/ProxyConfiguration.java index f79d15ef1d0b..c9448150ffa9 100644 --- a/core/src/main/java/hudson/ProxyConfiguration.java +++ b/core/src/main/java/hudson/ProxyConfiguration.java @@ -49,7 +49,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; import java.util.regex.Pattern; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.model.Jenkins; import jenkins.security.stapler.StaplerAccessibleType; import jenkins.util.JenkinsJVM; diff --git a/core/src/main/java/hudson/TcpSlaveAgentListener.java b/core/src/main/java/hudson/TcpSlaveAgentListener.java index dfe9f4ce20c2..d86b534fb1f1 100644 --- a/core/src/main/java/hudson/TcpSlaveAgentListener.java +++ b/core/src/main/java/hudson/TcpSlaveAgentListener.java @@ -29,7 +29,7 @@ import java.io.Writer; import java.nio.charset.StandardCharsets; import java.security.interfaces.RSAPublicKey; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; import hudson.model.AperiodicWork; import hudson.util.VersionNumber; diff --git a/core/src/main/java/hudson/Util.java b/core/src/main/java/hudson/Util.java index 558413824ab6..a10a8864e1b7 100644 --- a/core/src/main/java/hudson/Util.java +++ b/core/src/main/java/hudson/Util.java @@ -85,10 +85,10 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.CheckForNull; -import javax.annotation.CheckReturnValue; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckReturnValue; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; @@ -114,8 +114,8 @@ public class Util { * Creates a filtered sublist. * @since 1.176 */ - @Nonnull - public static List filter( @Nonnull Iterable base, @Nonnull Class type ) { + @NonNull + public static List filter( @NonNull Iterable base, @NonNull Class type ) { List r = new ArrayList<>(); for (Object i : base) { if(type.isInstance(i)) @@ -127,8 +127,8 @@ public static List filter( @Nonnull Iterable base, @Nonnull Class t /** * Creates a filtered sublist. */ - @Nonnull - public static List filter( @Nonnull List base, @Nonnull Class type ) { + @NonNull + public static List filter( @NonNull List base, @NonNull Class type ) { return filter((Iterable)base,type); } @@ -145,7 +145,7 @@ public static List filter( @Nonnull List base, @Nonnull Class type * */ @Nullable - public static String replaceMacro( @CheckForNull String s, @Nonnull Map properties) { + public static String replaceMacro( @CheckForNull String s, @NonNull Map properties) { return replaceMacro(s, new VariableResolver.ByMap<>(properties)); } @@ -156,7 +156,7 @@ public static String replaceMacro( @CheckForNull String s, @Nonnull Map resolver) { + public static String replaceMacro(@CheckForNull String s, @NonNull VariableResolver resolver) { if (s == null) { return null; } @@ -197,9 +197,9 @@ public static String replaceMacro(@CheckForNull String s, @Nonnull VariableResol * instead to specify the charset to use for decoding (preferably * {@link java.nio.charset.StandardCharsets#UTF_8}). */ - @Nonnull + @NonNull @Deprecated - public static String loadFile(@Nonnull File logfile) throws IOException { + public static String loadFile(@NonNull File logfile) throws IOException { return loadFile(logfile, Charset.defaultCharset()); } @@ -212,8 +212,8 @@ public static String loadFile(@Nonnull File logfile) throws IOException { * @return The entire text content of {@code logfile}. * @throws IOException If an error occurs while reading the file. */ - @Nonnull - public static String loadFile(@Nonnull File logfile, @Nonnull Charset charset) throws IOException { + @NonNull + public static String loadFile(@NonNull File logfile, @NonNull Charset charset) throws IOException { // Note: Until charset handling is resolved (e.g. by implementing // https://issues.jenkins-ci.org/browse/JENKINS-48923 ), this method // must be able to handle character encoding errors. As reported at @@ -246,7 +246,7 @@ public static String loadFile(@Nonnull File logfile, @Nonnull Charset charset) t * @throws IOException * if the operation fails. */ - public static void deleteContentsRecursive(@Nonnull File file) throws IOException { + public static void deleteContentsRecursive(@NonNull File file) throws IOException { deleteContentsRecursive(fileToPath(file), PathRemover.PathChecker.ALLOW_ALL); } @@ -257,7 +257,7 @@ public static void deleteContentsRecursive(@Nonnull File file) throws IOExceptio * @throws IOException if the operation fails */ @Restricted(NoExternalUse.class) - public static void deleteContentsRecursive(@Nonnull Path path, @Nonnull PathRemover.PathChecker pathChecker) throws IOException { + public static void deleteContentsRecursive(@NonNull Path path, @NonNull PathRemover.PathChecker pathChecker) throws IOException { newPathRemover(pathChecker).forceRemoveDirectoryContents(path); } @@ -268,7 +268,7 @@ public static void deleteContentsRecursive(@Nonnull Path path, @Nonnull PathRemo * @param f a file to delete * @throws IOException if it exists but could not be successfully deleted */ - public static void deleteFile(@Nonnull File f) throws IOException { + public static void deleteFile(@NonNull File f) throws IOException { newPathRemover(PathRemover.PathChecker.ALLOW_ALL).forceRemoveFile(fileToPath(f)); } @@ -280,7 +280,7 @@ public static void deleteFile(@Nonnull File f) throws IOException { * @throws IOException * if the operation fails. */ - public static void deleteRecursive(@Nonnull File dir) throws IOException { + public static void deleteRecursive(@NonNull File dir) throws IOException { deleteRecursive(fileToPath(dir), PathRemover.PathChecker.ALLOW_ALL); } @@ -291,7 +291,7 @@ public static void deleteRecursive(@Nonnull File dir) throws IOException { * @throws IOException if the operation fails */ @Restricted(NoExternalUse.class) - public static void deleteRecursive(@Nonnull Path dir, @Nonnull PathRemover.PathChecker pathChecker) throws IOException { + public static void deleteRecursive(@NonNull Path dir, @NonNull PathRemover.PathChecker pathChecker) throws IOException { newPathRemover(pathChecker).forceRemoveRecursive(dir); } @@ -315,12 +315,12 @@ public static void deleteRecursive(@Nonnull Path dir, @Nonnull PathRemover.PathC * considers NTFS junction points as symbolic * links. */ - public static boolean isSymlink(@Nonnull File file) throws IOException { + public static boolean isSymlink(@NonNull File file) throws IOException { return isSymlink(fileToPath(file)); } @Restricted(NoExternalUse.class) - public static boolean isSymlink(@Nonnull Path path) { + public static boolean isSymlink(@NonNull Path path) { /* * Windows Directory Junctions are effectively the same as Linux symlinks to directories. * Unfortunately, the Java 7 NIO2 API function isSymbolicLink does not treat them as such. @@ -412,14 +412,14 @@ public static File createTempDir() throws IOException { * On Windows, error messages for IOException aren't very helpful. * This method generates additional user-friendly error message to the listener */ - public static void displayIOException(@Nonnull IOException e, @Nonnull TaskListener listener ) { + public static void displayIOException(@NonNull IOException e, @NonNull TaskListener listener ) { String msg = getWin32ErrorMessage(e); if(msg!=null) listener.getLogger().println(msg); } @CheckForNull - public static String getWin32ErrorMessage(@Nonnull IOException e) { + public static String getWin32ErrorMessage(@NonNull IOException e) { return getWin32ErrorMessage((Throwable)e); } @@ -469,7 +469,7 @@ public static String getWin32ErrorMessage(int n) { /** * Guesses the current host name. */ - @Nonnull + @NonNull public static String getHostName() { try { return InetAddress.getLocalHost().getHostName(); @@ -482,7 +482,7 @@ public static String getHostName() { * @deprecated Use {@link IOUtils#copy(InputStream, OutputStream)} */ @Deprecated - public static void copyStream(@Nonnull InputStream in,@Nonnull OutputStream out) throws IOException { + public static void copyStream(@NonNull InputStream in,@NonNull OutputStream out) throws IOException { IOUtils.copy(in, out); } @@ -490,7 +490,7 @@ public static void copyStream(@Nonnull InputStream in,@Nonnull OutputStream out) * @deprecated Use {@link IOUtils#copy(Reader, Writer)} */ @Deprecated - public static void copyStream(@Nonnull Reader in, @Nonnull Writer out) throws IOException { + public static void copyStream(@NonNull Reader in, @NonNull Writer out) throws IOException { IOUtils.copy(in, out); } @@ -498,7 +498,7 @@ public static void copyStream(@Nonnull Reader in, @Nonnull Writer out) throws IO * @deprecated Use {@link IOUtils#copy(InputStream, OutputStream)} in a {@code try}-with-resources block */ @Deprecated - public static void copyStreamAndClose(@Nonnull InputStream in, @Nonnull OutputStream out) throws IOException { + public static void copyStreamAndClose(@NonNull InputStream in, @NonNull OutputStream out) throws IOException { try (InputStream _in = in; OutputStream _out = out) { // make sure both are closed, and use Throwable.addSuppressed IOUtils.copy(_in, _out); } @@ -508,7 +508,7 @@ public static void copyStreamAndClose(@Nonnull InputStream in, @Nonnull OutputSt * @deprecated Use {@link IOUtils#copy(Reader, Writer)} in a {@code try}-with-resources block */ @Deprecated - public static void copyStreamAndClose(@Nonnull Reader in, @Nonnull Writer out) throws IOException { + public static void copyStreamAndClose(@NonNull Reader in, @NonNull Writer out) throws IOException { try (Reader _in = in; Writer _out = out) { IOUtils.copy(_in, _out); } @@ -524,21 +524,21 @@ public static void copyStreamAndClose(@Nonnull Reader in, @Nonnull Writer out) t * @since 1.145 * @see QuotedStringTokenizer */ - @Nonnull - public static String[] tokenize(@Nonnull String s, @CheckForNull String delimiter) { + @NonNull + public static String[] tokenize(@NonNull String s, @CheckForNull String delimiter) { return QuotedStringTokenizer.tokenize(s,delimiter); } - @Nonnull - public static String[] tokenize(@Nonnull String s) { + @NonNull + public static String[] tokenize(@NonNull String s) { return tokenize(s," \t\n\r\f"); } /** * Converts the map format of the environment variables to the K=V format in the array. */ - @Nonnull - public static String[] mapToEnv(@Nonnull Map m) { + @NonNull + public static String[] mapToEnv(@NonNull Map m) { String[] r = new String[m.size()]; int idx=0; @@ -548,7 +548,7 @@ public static String[] mapToEnv(@Nonnull Map m) { return r; } - public static int min(int x, @Nonnull int... values) { + public static int min(int x, @NonNull int... values) { for (int i : values) { if(i=100) * So 13 minutes and 43 seconds returns just "13 minutes", but 3 minutes * and 43 seconds is "3 minutes 43 seconds". */ - @Nonnull + @NonNull private static String makeTimeSpanString(long bigUnit, - @Nonnull String bigLabel, + @NonNull String bigLabel, long smallUnit, - @Nonnull String smallLabel) { + @NonNull String smallLabel) { String text = bigLabel; if (bigUnit < 10) text += ' ' + smallLabel; @@ -769,7 +769,7 @@ private static String makeTimeSpanString(long bigUnit, * @deprecated Actually identical to {@link #getTimeSpanString}, does not add {@code ago}. */ @Deprecated - @Nonnull + @NonNull public static String getPastTimeString(long duration) { return getTimeSpanString(duration); } @@ -783,9 +783,9 @@ public static String getPastTimeString(long duration) { * See {@link Messages#Util_year(Object)} for an example. * Deprecated since 2009-06-24, remove method after 2009-12-24. */ - @Nonnull + @NonNull @Deprecated - public static String combine(long n, @Nonnull String suffix) { + public static String combine(long n, @NonNull String suffix) { String s = Long.toString(n)+' '+suffix; if(n!=1) // Just adding an 's' won't work in most natural languages, even English has exception to the rule (e.g. copy/copies). @@ -796,8 +796,8 @@ public static String combine(long n, @Nonnull String suffix) { /** * Create a sub-list by only picking up instances of the specified type. */ - @Nonnull - public static List createSubList(@Nonnull Collection source, @Nonnull Class type ) { + @NonNull + public static List createSubList(@NonNull Collection source, @NonNull Class type ) { List r = new ArrayList<>(); for (Object item : source) { if(type.isInstance(item)) @@ -815,8 +815,8 @@ public static List createSubList(@Nonnull Collection source, @Nonnull * {@link #rawEncode(String)} should generally be used instead, though be careful to pass only * a single path component to that method (it will encode /, but this method does not). */ - @Nonnull - public static String encode(@Nonnull String s) { + @NonNull + public static String encode(@NonNull String s) { try { boolean escaped = false; @@ -873,8 +873,8 @@ public static String encode(@Nonnull String s) { * single path component used in constructing a URL. * Method name inspired by PHP's rawurlencode. */ - @Nonnull - public static String rawEncode(@Nonnull String s) { + @NonNull + public static String rawEncode(@NonNull String s) { boolean escaped = false; StringBuilder out = null; CharsetEncoder enc = null; @@ -983,8 +983,8 @@ public static String escape(@CheckForNull String text) { return buf.toString(); } - @Nonnull - public static String xmlEscape(@Nonnull String text) { + @NonNull + public static String xmlEscape(@NonNull String text) { StringBuilder buf = new StringBuilder(text.length()+64); for( int i=0; i T fixNull(@CheckForNull T s, @Nonnull T defaultValue) { + @NonNull + public static T fixNull(@CheckForNull T s, @NonNull T defaultValue) { return s != null ? s : defaultValue; } @@ -1071,7 +1071,7 @@ public static String fixEmptyAndTrim(@CheckForNull String s) { * {@code l} if l is not {@code null}. * An empty immutable list if l is {@code null}. */ - @Nonnull + @NonNull public static List fixNull(@CheckForNull List l) { return fixNull(l, Collections.emptyList()); } @@ -1085,7 +1085,7 @@ public static List fixNull(@CheckForNull List l) { * {@code l} if l is not {@code null}. * An empty immutable set if l is {@code null}. */ - @Nonnull + @NonNull public static Set fixNull(@CheckForNull Set l) { return fixNull(l, Collections.emptySet()); } @@ -1099,7 +1099,7 @@ public static Set fixNull(@CheckForNull Set l) { * {@code l} if l is not {@code null}. * An empty immutable set if l is {@code null}. */ - @Nonnull + @NonNull public static Collection fixNull(@CheckForNull Collection l) { return fixNull(l, Collections.emptySet()); } @@ -1113,7 +1113,7 @@ public static Collection fixNull(@CheckForNull Collection l) { * {@code l} if l is not {@code null}. * An empty immutable set if l is {@code null}. */ - @Nonnull + @NonNull public static Iterable fixNull(@CheckForNull Iterable l) { return fixNull(l, Collections.emptySet()); } @@ -1121,8 +1121,8 @@ public static Iterable fixNull(@CheckForNull Iterable l) { /** * Cuts all the leading path portion and get just the file name. */ - @Nonnull - public static String getFileName(@Nonnull String filePath) { + @NonNull + public static String getFileName(@NonNull String filePath) { int idx = filePath.lastIndexOf('\\'); if(idx>=0) return getFileName(filePath.substring(idx+1)); @@ -1135,8 +1135,8 @@ public static String getFileName(@Nonnull String filePath) { /** * Concatenate multiple strings by inserting a separator. */ - @Nonnull - public static String join(@Nonnull Collection strings, @Nonnull String separator) { + @NonNull + public static String join(@NonNull Collection strings, @NonNull String separator) { StringBuilder buf = new StringBuilder(); boolean first=true; for (Object s : strings) { @@ -1150,8 +1150,8 @@ public static String join(@Nonnull Collection strings, @Nonnull String separa /** * Combines all the given collections into a single list. */ - @Nonnull - public static List join(@Nonnull Collection... items) { + @NonNull + public static List join(@NonNull Collection... items) { int size = 0; for (Collection item : items) size += item.size(); @@ -1178,8 +1178,8 @@ public static List join(@Nonnull Collection... items) { * Can be null. * @since 1.172 */ - @Nonnull - public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes, @CheckForNull String excludes) { + @NonNull + public static FileSet createFileSet(@NonNull File baseDir, @NonNull String includes, @CheckForNull String excludes) { FileSet fs = new FileSet(); fs.setDir(baseDir); fs.setProject(new Project()); @@ -1201,12 +1201,12 @@ public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String inclu return fs; } - @Nonnull - public static FileSet createFileSet(@Nonnull File baseDir, @Nonnull String includes) { + @NonNull + public static FileSet createFileSet(@NonNull File baseDir, @NonNull String includes) { return createFileSet(baseDir,includes,null); } - private static void tryToDeleteSymlink(@Nonnull File symlink) { + private static void tryToDeleteSymlink(@NonNull File symlink) { if (!symlink.delete()) { LogRecord record = new LogRecord(Level.FINE, "Failed to delete temporary symlink {0}"); record.setParameters(new Object[]{symlink.getAbsolutePath()}); @@ -1214,7 +1214,7 @@ private static void tryToDeleteSymlink(@Nonnull File symlink) { } } - private static void reportAtomicFailure(@Nonnull Path pathForSymlink, @Nonnull Exception ex) { + private static void reportAtomicFailure(@NonNull Path pathForSymlink, @NonNull Exception ex) { LogRecord record = new LogRecord(Level.FINE, "Failed to atomically create/replace symlink {0}"); record.setParameters(new Object[]{pathForSymlink.toAbsolutePath().toString()}); record.setThrown(ex); @@ -1236,7 +1236,7 @@ private static void reportAtomicFailure(@Nonnull Path pathForSymlink, @Nonnull E * Returns true on success */ @CheckReturnValue - private static boolean createSymlinkAtomic(@Nonnull Path pathForSymlink, @Nonnull File fileForSymlink, @Nonnull Path target, @Nonnull String symlinkPath) { + private static boolean createSymlinkAtomic(@NonNull Path pathForSymlink, @NonNull File fileForSymlink, @NonNull Path target, @NonNull String symlinkPath) { try { File symlink = File.createTempFile("symtmp", null, fileForSymlink); tryToDeleteSymlink(symlink); @@ -1277,8 +1277,8 @@ private static boolean createSymlinkAtomic(@Nonnull Path pathForSymlink, @Nonnul * @param symlinkPath * Where to create a symlink in (relative to {@code baseDir}) */ - public static void createSymlink(@Nonnull File baseDir, @Nonnull String targetPath, - @Nonnull String symlinkPath, @Nonnull TaskListener listener) throws InterruptedException { + public static void createSymlink(@NonNull File baseDir, @NonNull String targetPath, + @NonNull String symlinkPath, @NonNull TaskListener listener) throws InterruptedException { File fileForSymlink = new File(baseDir, symlinkPath); try { Path pathForSymlink = fileToPath(fileForSymlink); @@ -1342,7 +1342,7 @@ public static String resolveSymlink(File link, TaskListener listener) throws Int * if the specified file is not a symlink. */ @CheckForNull - public static File resolveSymlinkToFile(@Nonnull File link) throws InterruptedException, IOException { + public static File resolveSymlinkToFile(@NonNull File link) throws InterruptedException, IOException { String target = resolveSymlink(link); if (target==null) return null; @@ -1363,7 +1363,7 @@ public static File resolveSymlinkToFile(@Nonnull File link) throws InterruptedEx * The relative path is meant to be resolved from the location of the symlink. */ @CheckForNull - public static String resolveSymlink(@Nonnull File link) throws IOException { + public static String resolveSymlink(@NonNull File link) throws IOException { try { Path path = fileToPath(link); return Files.readSymbolicLink(path).toString(); @@ -1405,8 +1405,8 @@ public static String encodeRFC2396(String url) { * Wraps with the error icon and the CSS class to render error message. * @since 1.173 */ - @Nonnull - public static String wrapToErrorSpan(@Nonnull String s) { + @NonNull + public static String wrapToErrorSpan(@NonNull String s) { s = ""+s+""; return s; } @@ -1435,11 +1435,11 @@ public static Number tryParseNumber(@CheckForNull String numberStr, @CheckForNul * Checks if the method defined on the base type with the given arguments * is overridden in the given derived type. */ - public static boolean isOverridden(@Nonnull Class base, @Nonnull Class derived, @Nonnull String methodName, @Nonnull Class... types) { + public static boolean isOverridden(@NonNull Class base, @NonNull Class derived, @NonNull String methodName, @NonNull Class... types) { return !getMethod(base, methodName, types).equals(getMethod(derived, methodName, types)); } - private static Method getMethod(@Nonnull Class clazz, @Nonnull String methodName, @Nonnull Class... types) { + private static Method getMethod(@NonNull Class clazz, @NonNull String methodName, @NonNull Class... types) { Method res = null; try { res = clazz.getDeclaredMethod(methodName, types); @@ -1470,8 +1470,8 @@ private static Method getMethod(@Nonnull Class clazz, @Nonnull String methodName * @param ext * For example, ".zip" */ - @Nonnull - public static File changeExtension(@Nonnull File dst, @Nonnull String ext) { + @NonNull + public static File changeExtension(@NonNull File dst, @NonNull String ext) { String p = dst.getPath(); int pos = p.lastIndexOf('.'); if (pos<0) return new File(p+ext); @@ -1499,7 +1499,7 @@ public static String intern(@CheckForNull String s) { @Deprecated @RestrictedSince("1.651.2 / 2.TODO") @Restricted(NoExternalUse.class) - public static boolean isAbsoluteUri(@Nonnull String uri) { + public static boolean isAbsoluteUri(@NonNull String uri) { int idx = uri.indexOf(':'); if (idx<0) return false; // no ':'. can't be absolute @@ -1511,7 +1511,7 @@ public static boolean isAbsoluteUri(@Nonnull String uri) { * Return true iff the parameter does not denote an absolute URI and not a scheme-relative URI. * @since 2.3 / 1.651.2 */ - public static boolean isSafeToRedirectTo(@Nonnull String uri) { + public static boolean isSafeToRedirectTo(@NonNull String uri) { return !isAbsoluteUri(uri) && !uri.startsWith("//"); } @@ -1519,7 +1519,7 @@ public static boolean isSafeToRedirectTo(@Nonnull String uri) { * Works like {@link String#indexOf(int)} but 'not found' is returned as s.length(), not -1. * This enables more straight-forward comparison. */ - private static int _indexOf(@Nonnull String s, char ch) { + private static int _indexOf(@NonNull String s, char ch) { int idx = s.indexOf(ch); if (idx<0) return s.length(); return idx; @@ -1529,8 +1529,8 @@ private static int _indexOf(@Nonnull String s, char ch) { * Loads a key/value pair string as {@link Properties} * @since 1.392 */ - @Nonnull - public static Properties loadProperties(@Nonnull String properties) throws IOException { + @NonNull + public static Properties loadProperties(@NonNull String properties) throws IOException { Properties p = new Properties(); p.load(new StringReader(properties)); return p; @@ -1546,8 +1546,8 @@ public static Properties loadProperties(@Nonnull String properties) throws IOExc * @since 2.19, but TODO update once un-restricted */ @Restricted(NoExternalUse.class) - public static void closeAndLogFailures(@CheckForNull Closeable toClose, @Nonnull Logger logger, - @Nonnull String closeableName, @Nonnull String closeableOwner) { + public static void closeAndLogFailures(@CheckForNull Closeable toClose, @NonNull Logger logger, + @NonNull String closeableName, @NonNull String closeableOwner) { if (toClose == null) { return; } @@ -1598,7 +1598,7 @@ public static Set modeToPermissions(int mode) throws IOExce * @throws IOException if {@code f.toPath()} throws {@link InvalidPathException}. */ @Restricted(NoExternalUse.class) - public static @Nonnull Path fileToPath(@Nonnull File file) throws IOException { + public static @NonNull Path fileToPath(@NonNull File file) throws IOException { try { return file.toPath(); } catch (InvalidPathException e) { @@ -1612,7 +1612,7 @@ public static Set modeToPermissions(int mode) throws IOExce * even if there are only 3 hours between. As well as "10am" to "2pm" both on the same day, returns 0. */ @Restricted(NoExternalUse.class) - public static long daysBetween(@Nonnull Date a, @Nonnull Date b){ + public static long daysBetween(@NonNull Date a, @NonNull Date b){ LocalDate aLocal = a.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate bLocal = b.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); return ChronoUnit.DAYS.between(aLocal, bLocal); @@ -1623,7 +1623,7 @@ public static long daysBetween(@Nonnull Date a, @Nonnull Date b){ * @see #daysBetween(Date, Date) */ @Restricted(NoExternalUse.class) - public static long daysElapsedSince(@Nonnull Date date){ + public static long daysElapsedSince(@NonNull Date date){ return Math.max(0, daysBetween(date, new Date())); } @@ -1632,7 +1632,7 @@ public static long daysElapsedSince(@Nonnull Date date){ * Useful for an ancestor we know is inside the URL to ease readability */ @Restricted(NoExternalUse.class) - public static @Nonnull T getNearestAncestorOfTypeOrThrow(@Nonnull StaplerRequest request, @Nonnull Class clazz) { + public static @NonNull T getNearestAncestorOfTypeOrThrow(@NonNull StaplerRequest request, @NonNull Class clazz) { T t = request.findAncestorObject(clazz); if (t == null) { throw new IllegalArgumentException("No ancestor of type " + clazz.getName() + " in the request"); @@ -1708,7 +1708,7 @@ public static long daysElapsedSince(@Nonnull Date date){ @Restricted(value = NoExternalUse.class) static boolean GC_AFTER_FAILED_DELETE = SystemProperties.getBoolean(Util.class.getName() + ".performGCOnFailedDelete"); - private static PathRemover newPathRemover(@Nonnull PathRemover.PathChecker pathChecker) { + private static PathRemover newPathRemover(@NonNull PathRemover.PathChecker pathChecker) { return PathRemover.newFilteredRobustRemover(pathChecker, DELETION_RETRIES, GC_AFTER_FAILED_DELETE, WAIT_BETWEEN_DELETION_RETRIES); } diff --git a/core/src/main/java/hudson/cli/CLICommand.java b/core/src/main/java/hudson/cli/CLICommand.java index 68747a6a8c06..52888990c5cd 100644 --- a/core/src/main/java/hudson/cli/CLICommand.java +++ b/core/src/main/java/hudson/cli/CLICommand.java @@ -64,8 +64,8 @@ import java.util.UUID; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Base class for Hudson CLI. @@ -461,11 +461,11 @@ protected String getClientSystemProperty(String name) throws IOException, Interr * Define the encoding for the command. * @since 2.54 */ - public void setClientCharset(@Nonnull Charset encoding) { + public void setClientCharset(@NonNull Charset encoding) { this.encoding = encoding; } - protected @Nonnull Charset getClientCharset() throws IOException, InterruptedException { + protected @NonNull Charset getClientCharset() throws IOException, InterruptedException { if (encoding != null) { return encoding; } diff --git a/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java b/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java index f8363f32503f..7b997eb17798 100644 --- a/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java +++ b/core/src/main/java/hudson/cli/declarative/CLIRegisterer.java @@ -45,7 +45,7 @@ import org.kohsuke.args4j.CmdLineParser; import org.kohsuke.args4j.CmdLineException; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; @@ -97,7 +97,7 @@ private Method findResolver(Class type) throws IOException { return null; } - private List> discover(@Nonnull final Jenkins jenkins) { + private List> discover(@NonNull final Jenkins jenkins) { LOGGER.fine("Listing up @CLIMethod"); List> r = new ArrayList<>(); diff --git a/core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java b/core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java index 2c901b06b4b1..3c8a52d07e86 100644 --- a/core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java +++ b/core/src/main/java/hudson/cli/handlers/ViewOptionHandler.java @@ -39,7 +39,7 @@ import org.kohsuke.args4j.spi.Parameters; import org.kohsuke.args4j.spi.Setter; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Refers to {@link View} by its name. diff --git a/core/src/main/java/hudson/console/AnnotatedLargeText.java b/core/src/main/java/hudson/console/AnnotatedLargeText.java index 36d2664e9208..9790bf82071a 100644 --- a/core/src/main/java/hudson/console/AnnotatedLargeText.java +++ b/core/src/main/java/hudson/console/AnnotatedLargeText.java @@ -55,7 +55,7 @@ import com.jcraft.jzlib.GZIPOutputStream; import static java.lang.Math.abs; -import javax.annotation.CheckReturnValue; +import edu.umd.cs.findbugs.annotations.CheckReturnValue; import org.jenkinsci.remoting.util.AnonymousClassWarnings; /** diff --git a/core/src/main/java/hudson/console/ConsoleAnnotator.java b/core/src/main/java/hudson/console/ConsoleAnnotator.java index 9701eb302f04..cc28c35452fa 100644 --- a/core/src/main/java/hudson/console/ConsoleAnnotator.java +++ b/core/src/main/java/hudson/console/ConsoleAnnotator.java @@ -30,8 +30,8 @@ import java.util.Collection; import java.util.List; import java.util.ListIterator; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Annotates one line of console output. @@ -82,7 +82,7 @@ public abstract class ConsoleAnnotator implements Serializable { * To indicate that you are not interested in the following lines, return {@code null}. */ @CheckForNull - public abstract ConsoleAnnotator annotate(@Nonnull T context, @Nonnull MarkupText text ); + public abstract ConsoleAnnotator annotate(@NonNull T context, @NonNull MarkupText text ); /** * Cast operation that restricts T. diff --git a/core/src/main/java/hudson/console/ConsoleLogFilter.java b/core/src/main/java/hudson/console/ConsoleLogFilter.java index 24b2c73c1068..3ccdfd6c48d3 100644 --- a/core/src/main/java/hudson/console/ConsoleLogFilter.java +++ b/core/src/main/java/hudson/console/ConsoleLogFilter.java @@ -33,7 +33,7 @@ import hudson.tasks.BuildWrapper; import hudson.util.ArgumentListBuilder; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.io.OutputStream; import java.io.Serializable; @@ -102,7 +102,7 @@ public OutputStream decorateLogger(Run build, OutputStream logger) throws IOExce * contextual decoration. * @since 1.632 */ - public OutputStream decorateLogger(@Nonnull Computer computer, OutputStream logger) throws IOException, InterruptedException { + public OutputStream decorateLogger(@NonNull Computer computer, OutputStream logger) throws IOException, InterruptedException { return logger; // by default no-op } diff --git a/core/src/main/java/hudson/console/ModelHyperlinkNote.java b/core/src/main/java/hudson/console/ModelHyperlinkNote.java index cc3b8c3cb23b..a6e03015dc0b 100644 --- a/core/src/main/java/hudson/console/ModelHyperlinkNote.java +++ b/core/src/main/java/hudson/console/ModelHyperlinkNote.java @@ -6,7 +6,7 @@ import org.jenkinsci.Symbol; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * {@link HyperlinkNote} that links to a {@linkplain ModelObject model object}, @@ -25,7 +25,7 @@ protected String extraAttributes() { return " class='model-link'"; } - public static String encodeTo(@Nonnull User u) { + public static String encodeTo(@NonNull User u) { return encodeTo(u,u.getDisplayName()); } diff --git a/core/src/main/java/hudson/diagnosis/OldDataMonitor.java b/core/src/main/java/hudson/diagnosis/OldDataMonitor.java index 2de5802c709b..82dbffcf085a 100644 --- a/core/src/main/java/hudson/diagnosis/OldDataMonitor.java +++ b/core/src/main/java/hudson/diagnosis/OldDataMonitor.java @@ -53,8 +53,8 @@ import java.util.concurrent.ConcurrentMap; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import org.jenkinsci.Symbol; @@ -86,7 +86,7 @@ public class OldDataMonitor extends AdministrativeMonitor { * @throws IllegalStateException Monitor not found. * It should never happen since the monitor is located in the core. */ - @Nonnull + @NonNull static OldDataMonitor get(Jenkins j) throws IllegalStateException { return ExtensionList.lookupSingleton(OldDataMonitor.class); } @@ -440,7 +440,7 @@ private static final class RunSaveableReference implements SaveableReference { @Extension @Symbol("oldData") public static class ManagementLinkImpl extends ManagementLink { - @Nonnull + @NonNull @Override public Category getCategory() { return Category.TROUBLESHOOTING; diff --git a/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java b/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java index b0916e14b428..ccce1d159c2f 100644 --- a/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java +++ b/core/src/main/java/hudson/init/impl/InstallUncaughtExceptionHandler.java @@ -13,7 +13,7 @@ import org.kohsuke.stapler.WebApp; import org.kohsuke.stapler.compression.CompressionFilter; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java index 266b52e8be61..92a75d850f1e 100644 --- a/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java +++ b/core/src/main/java/hudson/lifecycle/WindowsInstallerLink.java @@ -53,7 +53,7 @@ import org.apache.tools.ant.types.FileSet; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import java.io.File; import java.io.IOException; @@ -102,7 +102,7 @@ public String getDescription() { } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.CONFIGURATION; diff --git a/core/src/main/java/hudson/markup/MarkupFormatter.java b/core/src/main/java/hudson/markup/MarkupFormatter.java index be8004136ab2..5bec9ab0a300 100644 --- a/core/src/main/java/hudson/markup/MarkupFormatter.java +++ b/core/src/main/java/hudson/markup/MarkupFormatter.java @@ -29,8 +29,8 @@ import java.io.IOException; import java.io.StringWriter; import java.io.Writer; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.QueryParameter; @@ -69,9 +69,9 @@ public abstract class MarkupFormatter extends AbstractDescribableImpl getCulprits() { + @NonNull public Set getCulprits() { return RunWithSCM.super.getCulprits(); } @@ -336,7 +336,7 @@ public boolean shouldCalculateCulprits() { } @Override - @Nonnull + @NonNull public Set calculateCulprits() { Set c = RunWithSCM.super.calculateCulprits(); @@ -404,7 +404,7 @@ deprecated class here. * @return Returns the current {@link Node} * @throws IllegalStateException if that cannot be determined */ - protected final @Nonnull Node getCurrentNode() throws IllegalStateException { + protected final @NonNull Node getCurrentNode() throws IllegalStateException { Executor exec = Executor.currentExecutor(); if (exec == null) { throw new IllegalStateException("not being called from an executor thread"); @@ -433,7 +433,7 @@ public BuildListener getListener() { * @param wsl * Passed in for the convenience. The returned path must be registered to this object. */ - protected Lease decideWorkspace(@Nonnull Node n, WorkspaceList wsl) throws InterruptedException, IOException { + protected Lease decideWorkspace(@NonNull Node n, WorkspaceList wsl) throws InterruptedException, IOException { String customWorkspace = getProject().getCustomWorkspace(); if (customWorkspace != null) { FilePath rootPath = n.getRootPath(); @@ -451,7 +451,7 @@ protected Lease decideWorkspace(@Nonnull Node n, WorkspaceList wsl) throws Inter return wsl.allocate(ws, getBuild()); } - public Result run(@Nonnull BuildListener listener) throws Exception { + public Result run(@NonNull BuildListener listener) throws Exception { final Node node = getCurrentNode(); assert builtOn==null; @@ -525,8 +525,8 @@ public Result run(@Nonnull BuildListener listener) throws Exception { * @param listener * Always non-null. Connected to the main build output. */ - @Nonnull - protected Launcher createLauncher(@Nonnull BuildListener listener) throws IOException, InterruptedException { + @NonNull + protected Launcher createLauncher(@NonNull BuildListener listener) throws IOException, InterruptedException { final Node currentNode = getCurrentNode(); Launcher l = currentNode.createLauncher(listener); @@ -808,7 +808,7 @@ protected final boolean preBuild(BuildListener listener,Iterable getChangeSet() { + @NonNull public ChangeLogSet getChangeSet() { synchronized (changeSetLock) { if (scm==null) { scm = NullChangeLogParser.INSTANCE; @@ -833,7 +833,7 @@ protected final boolean preBuild(BuildListener listener,Iterable> getChangeSets() { + @NonNull public List> getChangeSets() { ChangeLogSet cs = getChangeSet(); return cs.isEmptySet() ? Collections.emptyList() : Collections.singletonList(cs); } diff --git a/core/src/main/java/hudson/model/AbstractCIBase.java b/core/src/main/java/hudson/model/AbstractCIBase.java index d23a35d59f84..6827993a94cb 100644 --- a/core/src/main/java/hudson/model/AbstractCIBase.java +++ b/core/src/main/java/hudson/model/AbstractCIBase.java @@ -40,7 +40,7 @@ import java.util.concurrent.CopyOnWriteArraySet; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.model.Configuration; diff --git a/core/src/main/java/hudson/model/AbstractItem.java b/core/src/main/java/hudson/model/AbstractItem.java index 19ef1b22422c..17025e877287 100644 --- a/core/src/main/java/hudson/model/AbstractItem.java +++ b/core/src/main/java/hudson/model/AbstractItem.java @@ -73,7 +73,7 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.acegisecurity.AccessDeniedException; import org.kohsuke.stapler.HttpResponse; @@ -204,7 +204,7 @@ public File getRootDir() { * This bridge method is to maintain binary compatibility with {@link TopLevelItem#getParent()}. */ @WithBridgeMethods(value=Jenkins.class,castRequired=true) - @Override public @Nonnull ItemGroup getParent() { + @Override public @NonNull ItemGroup getParent() { if (parent == null) { throw new IllegalStateException("no parent set on " + getClass().getName() + "[" + name + "]"); } @@ -273,7 +273,7 @@ public HttpResponse doConfirmRename(@QueryParameter String newName) throws IOExc * {@link FormValidation#error} with a message explaining the problem. */ @Restricted(NoExternalUse.class) - public @Nonnull FormValidation doCheckNewName(@QueryParameter String newName) { + public @NonNull FormValidation doCheckNewName(@QueryParameter String newName) { if (!isNameEditable()) { return FormValidation.error("Trying to rename an item that does not support this operation."); @@ -307,7 +307,7 @@ public HttpResponse doConfirmRename(@QueryParameter String newName) throws IOExc * Check new name for job * @param newName - New name for job. */ - private void checkIfNameIsUsed(@Nonnull String newName) throws Failure { + private void checkIfNameIsUsed(@NonNull String newName) throws Failure { try { Item item = getParent().getItem(newName); if (item != null) { @@ -345,7 +345,7 @@ private void checkIfNameIsUsed(@Nonnull String newName) throws Failure { * @since 2.110 * @see Job#checkRename */ - protected void checkRename(@Nonnull String newName) throws Failure { + protected void checkRename(@NonNull String newName) throws Failure { } diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 00a82dbf695a..c3dad5d065f1 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -95,8 +95,8 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import jenkins.model.BlockedBecauseOfBuildInProgress; import jenkins.model.Jenkins; @@ -1019,7 +1019,7 @@ public Object getSameNodeConstraint() { */ @Deprecated public static class BecauseOfBuildInProgress extends BlockedBecauseOfBuildInProgress { - public BecauseOfBuildInProgress(@Nonnull AbstractBuild build) { + public BecauseOfBuildInProgress(@NonNull AbstractBuild build) { super(build); } } @@ -1391,7 +1391,7 @@ private PollingResult _poll(TaskListener listener, SCM scm) throws IOException, } } - private PollingResult pollWithWorkspace(TaskListener listener, SCM scm, R lb, @Nonnull FilePath ws, WorkspaceList l) throws InterruptedException, IOException { + private PollingResult pollWithWorkspace(TaskListener listener, SCM scm, R lb, @NonNull FilePath ws, WorkspaceList l) throws InterruptedException, IOException { // if doing non-concurrent build, acquire a workspace in a way that causes builds to block for this workspace. // this prevents multiple workspaces of the same job --- the behavior of Hudson < 1.319. // @@ -1922,7 +1922,7 @@ public FormValidation doCheckLabel(@AncestorInPath AbstractProject project, * @param project May be specified to perform project specific validation. * @since 1.590 */ - public static @Nonnull FormValidation validateLabelExpression(String value, @CheckForNull AbstractProject project) { + public static @NonNull FormValidation validateLabelExpression(String value, @CheckForNull AbstractProject project) { if (Util.fixEmpty(value)==null) return FormValidation.ok(); // nothing typed yet try { @@ -2137,8 +2137,8 @@ public static abstract class LabelValidator implements ExtensionPoint { * @param label the label that the project wants to restrict itself to. * @return the {@link FormValidation} result. */ - @Nonnull - public abstract FormValidation check(@Nonnull AbstractProject project, @Nonnull Label label); + @NonNull + public abstract FormValidation check(@NonNull AbstractProject project, @NonNull Label label); } } diff --git a/core/src/main/java/hudson/model/Action.java b/core/src/main/java/hudson/model/Action.java index 72d2f84e065a..0b80bc36fb09 100644 --- a/core/src/main/java/hudson/model/Action.java +++ b/core/src/main/java/hudson/model/Action.java @@ -25,7 +25,7 @@ import hudson.Functions; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Object that contributes additional information, behaviors, and UIs to {@link ModelObject} diff --git a/core/src/main/java/hudson/model/Actionable.java b/core/src/main/java/hudson/model/Actionable.java index 174bf192ff22..17c5fa3b8ea8 100644 --- a/core/src/main/java/hudson/model/Actionable.java +++ b/core/src/main/java/hudson/model/Actionable.java @@ -32,8 +32,8 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import jenkins.model.ModelObjectWithContextMenu; import jenkins.model.TransientActionFactory; import org.kohsuke.stapler.StaplerRequest; @@ -72,7 +72,7 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj * May still be called for compatibility reasons from subclasses predating {@link TransientActionFactory}. */ @Deprecated - @Nonnull + @NonNull public List getActions() { //this double checked synchronization is only safe if the field 'actions' is volatile if (actions == null) { @@ -92,7 +92,7 @@ public List getActions() { * @since 1.548 */ @Exported(name="actions") - @Nonnull + @NonNull public final List getAllActions() { List _actions = getActions(); boolean adding = false; @@ -132,7 +132,7 @@ private Collection createFor(TransientActionFactory taf * @return an unmodifiable, possible empty list * @see #getAction(Class) */ - @Nonnull + @NonNull public List getActions(Class type) { List _actions = Util.filter(getActions(), type); for (TransientActionFactory taf : TransientActionFactory.factoriesFor(getClass(), type)) { @@ -148,7 +148,7 @@ public List getActions(Class type) { */ @SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") - public void addAction(@Nonnull Action a) { + public void addAction(@NonNull Action a) { if(a==null) { throw new IllegalArgumentException("Action must be non-null"); } @@ -172,7 +172,7 @@ public void addAction(@Nonnull Action a) { */ @SuppressWarnings({"ConstantConditions", "deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") - public void replaceAction(@Nonnull Action a) { + public void replaceAction(@NonNull Action a) { addOrReplaceAction(a); } @@ -191,7 +191,7 @@ public void replaceAction(@Nonnull Action a) { */ @SuppressWarnings({"ConstantConditions", "deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") - public boolean addOrReplaceAction(@Nonnull Action a) { + public boolean addOrReplaceAction(@NonNull Action a) { if (a == null) { throw new IllegalArgumentException("Action must be non-null"); } @@ -250,7 +250,7 @@ public boolean removeAction(@Nullable Action a) { */ @SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") - public boolean removeActions(@Nonnull Class clazz) { + public boolean removeActions(@NonNull Class clazz) { if (clazz == null) { throw new IllegalArgumentException("Action type must be non-null"); } @@ -282,7 +282,7 @@ public boolean removeActions(@Nonnull Class clazz) { */ @SuppressWarnings({"ConstantConditions", "deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") - public boolean replaceActions(@Nonnull Class clazz, @Nonnull Action a) { + public boolean replaceActions(@NonNull Class clazz, @NonNull Action a) { if (clazz == null) { throw new IllegalArgumentException("Action type must be non-null"); } diff --git a/core/src/main/java/hudson/model/AllView.java b/core/src/main/java/hudson/model/AllView.java index 4daedafd5a92..cdcb633f10ff 100644 --- a/core/src/main/java/hudson/model/AllView.java +++ b/core/src/main/java/hudson/model/AllView.java @@ -27,7 +27,7 @@ import java.util.Locale; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.util.SystemProperties; import org.apache.commons.lang.StringUtils; import org.jenkinsci.Symbol; @@ -133,9 +133,9 @@ protected void submit(StaplerRequest req) throws IOException, ServletException, * matching name is detected, in which case this will be the new name of the primary view. * @since 2.37 */ - @Nonnull - public static String migrateLegacyPrimaryAllViewLocalizedName(@Nonnull List views, - @Nonnull String primaryView) { + @NonNull + public static String migrateLegacyPrimaryAllViewLocalizedName(@NonNull List views, + @NonNull String primaryView) { if (DEFAULT_VIEW_NAME.equals(primaryView)) { // modern name, we are safe return primaryView; diff --git a/core/src/main/java/hudson/model/AutoCompletionCandidates.java b/core/src/main/java/hudson/model/AutoCompletionCandidates.java index 735a9b80e8a1..a54c6d6c7c9c 100644 --- a/core/src/main/java/hudson/model/AutoCompletionCandidates.java +++ b/core/src/main/java/hudson/model/AutoCompletionCandidates.java @@ -37,7 +37,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.apache.commons.lang.StringUtils; /** diff --git a/core/src/main/java/hudson/model/Build.java b/core/src/main/java/hudson/model/Build.java index 00f9c21d4eb4..da3891307b76 100644 --- a/core/src/main/java/hudson/model/Build.java +++ b/core/src/main/java/hudson/model/Build.java @@ -43,7 +43,7 @@ import java.util.logging.Level; import static hudson.model.Result.FAILURE; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * A build of a {@link Project}. @@ -139,7 +139,7 @@ protected class BuildExecution extends AbstractRunner { deprecated class here. */ - protected Result doRun(@Nonnull BuildListener listener) throws Exception { + protected Result doRun(@NonNull BuildListener listener) throws Exception { if(!preBuild(listener,project.getBuilders())) return FAILURE; if(!preBuild(listener,project.getPublishersList())) @@ -182,7 +182,7 @@ protected Result doRun(@Nonnull BuildListener listener) throws Exception { return r; } - public void post2(@Nonnull BuildListener listener) throws IOException, InterruptedException { + public void post2(@NonNull BuildListener listener) throws IOException, InterruptedException { if (!performAllBuildSteps(listener, project.getPublishersList(), true)) setResult(FAILURE); if (!performAllBuildSteps(listener, project.getProperties(), true)) @@ -190,7 +190,7 @@ public void post2(@Nonnull BuildListener listener) throws IOException, Interrupt } @Override - public void cleanUp(@Nonnull BuildListener listener) throws Exception { + public void cleanUp(@NonNull BuildListener listener) throws Exception { // at this point it's too late to mark the build as a failure, so ignore return value. try { performAllBuildSteps(listener, project.getPublishersList(), false); @@ -201,7 +201,7 @@ public void cleanUp(@Nonnull BuildListener listener) throws Exception { super.cleanUp(listener); } - private boolean build(@Nonnull BuildListener listener, @Nonnull Collection steps) throws IOException, InterruptedException { + private boolean build(@NonNull BuildListener listener, @NonNull Collection steps) throws IOException, InterruptedException { for( BuildStep bs : steps ) { if(!perform(bs,listener)) { LOGGER.log(Level.FINE, "{0} : {1} failed", new Object[] {Build.this, bs}); diff --git a/core/src/main/java/hudson/model/Cause.java b/core/src/main/java/hudson/model/Cause.java index 08f66552363e..c598829feeca 100644 --- a/core/src/main/java/hudson/model/Cause.java +++ b/core/src/main/java/hudson/model/Cause.java @@ -41,8 +41,8 @@ import java.util.HashSet; import java.util.Objects; import java.util.Set; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Cause object base class. This class hierarchy is used to keep track of why @@ -76,7 +76,7 @@ public abstract class Cause { * Called when the cause is registered. * @since 1.568 */ - public void onAddedTo(@Nonnull Run build) { + public void onAddedTo(@NonNull Run build) { if (build instanceof AbstractBuild) { onAddedTo((AbstractBuild) build); } @@ -95,13 +95,13 @@ public void onAddedTo(AbstractBuild build) { * this ought to be {@code transient}. * @since 1.568 */ - public void onLoad(@Nonnull Run build) { + public void onLoad(@NonNull Run build) { if (build instanceof AbstractBuild) { onLoad((AbstractBuild) build); } } - void onLoad(@Nonnull Job job, int buildNumber) { + void onLoad(@NonNull Job job, int buildNumber) { Run build = job.getBuildByNumber(buildNumber); if (build != null) { onLoad(build); @@ -160,7 +160,7 @@ public static class UpstreamCause extends Cause { */ @Deprecated private transient Cause upstreamCause; - private @Nonnull List upstreamCauses; + private @NonNull List upstreamCauses; /** * @deprecated since 2009-02-28 @@ -182,7 +182,7 @@ public UpstreamCause(Run up) { } } - private UpstreamCause(String upstreamProject, int upstreamBuild, String upstreamUrl, @Nonnull List upstreamCauses) { + private UpstreamCause(String upstreamProject, int upstreamBuild, String upstreamUrl, @NonNull List upstreamCauses) { this.upstreamProject = upstreamProject; this.upstreamBuild = upstreamBuild; this.upstreamUrl = upstreamUrl; @@ -190,7 +190,7 @@ private UpstreamCause(String upstreamProject, int upstreamBuild, String upstream } @Override - public void onLoad(@Nonnull Job _job, int _buildNumber) { + public void onLoad(@NonNull Job _job, int _buildNumber) { Item i = Jenkins.get().getItemByFullName(this.upstreamProject); if (!(i instanceof Job)) { // cannot initialize upstream causes @@ -229,7 +229,7 @@ public int hashCode() { return Objects.hash(upstreamCauses, upstreamBuild, upstreamUrl, upstreamProject); } - private @Nonnull Cause trim(@Nonnull Cause c, int depth, Set traversed) { + private @NonNull Cause trim(@NonNull Cause c, int depth, Set traversed) { if (!(c instanceof UpstreamCause)) { return c; } @@ -347,7 +347,7 @@ public static class DeeplyNestedUpstreamCause extends Cause { @Override public String toString() { return "JENKINS-14814"; } - @Override public void onLoad(@Nonnull Job _job, int _buildNumber) {} + @Override public void onLoad(@NonNull Job _job, int _buildNumber) {} } } @@ -426,7 +426,7 @@ public String getUserId() { return userId; } - @Nonnull + @NonNull private String getUserIdOrUnknown() { return userId != null ? userId : User.getUnknown().getId(); } diff --git a/core/src/main/java/hudson/model/CheckPoint.java b/core/src/main/java/hudson/model/CheckPoint.java index ab4e176f6f24..ebb78223b98f 100644 --- a/core/src/main/java/hudson/model/CheckPoint.java +++ b/core/src/main/java/hudson/model/CheckPoint.java @@ -27,7 +27,7 @@ import hudson.tasks.Recorder; import hudson.tasks.Builder; import hudson.scm.SCM; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Provides a mechanism for synchronizing build executions in the face of concurrent builds. @@ -153,7 +153,7 @@ public void block() throws InterruptedException { * @throws InterruptedException if the build is aborted while waiting * @since 1.528 */ - public void block(@Nonnull BuildListener listener, @Nonnull String waiter) throws InterruptedException { + public void block(@NonNull BuildListener listener, @NonNull String waiter) throws InterruptedException { Run.waitForCheckpoint(this, listener, waiter); } diff --git a/core/src/main/java/hudson/model/ChoiceParameterDefinition.java b/core/src/main/java/hudson/model/ChoiceParameterDefinition.java index 612925bce466..ab27de85a1e1 100644 --- a/core/src/main/java/hudson/model/ChoiceParameterDefinition.java +++ b/core/src/main/java/hudson/model/ChoiceParameterDefinition.java @@ -13,9 +13,9 @@ import net.sf.json.JSONObject; import hudson.Extension; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Arrays; @@ -38,19 +38,19 @@ public static boolean areValidChoices(String choices) { return !StringUtils.isEmpty(strippedChoices) && strippedChoices.split(CHOICES_DELIMITER).length > 0; } - public ChoiceParameterDefinition(@Nonnull String name, @Nonnull String choices, String description) { + public ChoiceParameterDefinition(@NonNull String name, @NonNull String choices, String description) { super(name, description); setChoicesText(choices); defaultValue = null; } - public ChoiceParameterDefinition(@Nonnull String name, @Nonnull String[] choices, String description) { + public ChoiceParameterDefinition(@NonNull String name, @NonNull String[] choices, String description) { super(name, description); this.choices = new ArrayList<>(Arrays.asList(choices)); defaultValue = null; } - private ChoiceParameterDefinition(@Nonnull String name, @Nonnull List choices, String defaultValue, String description) { + private ChoiceParameterDefinition(@NonNull String name, @NonNull List choices, String defaultValue, String description) { super(name, description); this.choices = choices; this.defaultValue = defaultValue; @@ -174,7 +174,7 @@ public String getHelpFile() { /* * We need this for JENKINS-26143 -- reflective creation cannot handle setChoices(Object). See that method for context. */ - public ParameterDefinition newInstance(@Nullable StaplerRequest req, @Nonnull JSONObject formData) throws FormException { + public ParameterDefinition newInstance(@Nullable StaplerRequest req, @NonNull JSONObject formData) throws FormException { String name = formData.getString("name"); String desc = formData.getString("description"); String choiceText = formData.getString("choices"); diff --git a/core/src/main/java/hudson/model/Computer.java b/core/src/main/java/hudson/model/Computer.java index b474701a154b..073af962c8f5 100644 --- a/core/src/main/java/hudson/model/Computer.java +++ b/core/src/main/java/hudson/model/Computer.java @@ -92,8 +92,8 @@ import org.kohsuke.stapler.interceptor.RequirePOST; import org.kohsuke.stapler.verb.POST; -import javax.annotation.OverridingMethodsMustInvokeSuper; -import javax.annotation.concurrent.GuardedBy; +import edu.umd.cs.findbugs.annotations.OverrideMustInvoke; +import net.jcip.annotations.GuardedBy; import javax.servlet.ServletException; import java.io.File; @@ -118,9 +118,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import static javax.servlet.http.HttpServletResponse.*; @@ -275,7 +275,7 @@ public List getActions() { @SuppressWarnings({"ConstantConditions","deprecation"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") @Override - public void addAction(@Nonnull Action a) { + public void addAction(@NonNull Action a) { if (a == null) { throw new IllegalArgumentException("Action must be non-null"); } @@ -290,7 +290,7 @@ public void addAction(@Nonnull Action a) { * @see #getLogDir() * @see #relocateOldLogs() */ - public @Nonnull File getLogFile() { + public @NonNull File getLogFile() { return new File(getLogDir(),"slave.log"); } @@ -301,7 +301,7 @@ public void addAction(@Nonnull Action a) { * * @since 1.613 */ - protected @Nonnull File getLogDir() { + protected @NonNull File getLogDir() { File dir = new File(Jenkins.get().getRootDir(),"logs/slaves/"+nodeName); try { IOUtils.mkdirs(dir); @@ -563,7 +563,7 @@ public int getNumExecutors() { /** * Returns {@link Node#getNodeName() the name of the node}. */ - public @Nonnull String getName() { + public @NonNull String getName() { return nodeName != null ? nodeName : ""; } @@ -763,7 +763,7 @@ public String getIconAltText() { } @Exported - @Override public @Nonnull String getDisplayName() { + @Override public @NonNull String getDisplayName() { return nodeName; } @@ -1074,7 +1074,7 @@ public final long getDemandStartMilliseconds() { */ @Restricted(DoNotUse.class) @Exported - public @Nonnull String getDescription() { + public @NonNull String getDescription() { Node node = getNode(); return (node != null) ? node.getNodeDescription() : ""; } @@ -1197,7 +1197,7 @@ public EnvVars getEnvironment() throws IOException, InterruptedException { * @see ProcStarter#envs(Map) * @since 1.489 */ - public @Nonnull EnvVars buildEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException { + public @NonNull EnvVars buildEnvironment(@NonNull TaskListener listener) throws IOException, InterruptedException { EnvVars env = new EnvVars(); Node node = getNode(); @@ -1626,7 +1626,7 @@ public Object getTarget() { * @see hudson.slaves.RetentionStrategy#isAcceptingTasks(Computer) * @see hudson.model.Node#isAcceptingTasks() */ - @OverridingMethodsMustInvokeSuper + @OverrideMustInvoke public boolean isAcceptingTasks() { final Node node = getNode(); return getRetentionStrategy().isAcceptingTasks(this) && (node == null || node.isAcceptingTasks()); @@ -1698,31 +1698,31 @@ public boolean accept(File dir, String name) { @Restricted(NoExternalUse.class) public static class DisplayExecutor implements ModelObject { - @Nonnull + @NonNull private final String displayName; - @Nonnull + @NonNull private final String url; - @Nonnull + @NonNull private final Executor executor; - public DisplayExecutor(@Nonnull String displayName, @Nonnull String url, @Nonnull Executor executor) { + public DisplayExecutor(@NonNull String displayName, @NonNull String url, @NonNull Executor executor) { this.displayName = displayName; this.url = url; this.executor = executor; } @Override - @Nonnull + @NonNull public String getDisplayName() { return displayName; } - @Nonnull + @NonNull public String getUrl() { return url; } - @Nonnull + @NonNull public Executor getExecutor() { return executor; } diff --git a/core/src/main/java/hudson/model/ComputerSet.java b/core/src/main/java/hudson/model/ComputerSet.java index 7fafbf68c7cb..151221621a84 100644 --- a/core/src/main/java/hudson/model/ComputerSet.java +++ b/core/src/main/java/hudson/model/ComputerSet.java @@ -49,7 +49,7 @@ import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import java.io.File; import java.io.IOException; @@ -416,7 +416,7 @@ public void doRun() { * @return The list of strings of computer names (excluding master) * @since 2.14 */ - @Nonnull + @NonNull public static List getComputerNames() { final ArrayList names = new ArrayList<>(); for (Computer c : Jenkins.get().getComputers()) { diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 431f9f2bf207..61df11f2f64c 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -81,9 +81,9 @@ import java.lang.reflect.ParameterizedType; import java.beans.Introspector; import java.util.IdentityHashMap; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; /** * Metadata about a configurable instance. @@ -310,7 +310,7 @@ protected Descriptor() { * Historically some implementations returned null as a way of hiding the descriptor from the UI, * but this is generally managed by an explicit method such as {@code isEnabled} or {@code isApplicable}. */ - @Nonnull + @NonNull public String getDisplayName() { return clazz.getSimpleName(); } @@ -466,7 +466,7 @@ public void calcAutoCompleteSettings(String field, Map attributes /** * Used by Jelly to abstract away the handling of global.jelly vs config.jelly databinding difference. */ - public @CheckForNull PropertyType getPropertyType(@Nonnull Object instance, @Nonnull String field) { + public @CheckForNull PropertyType getPropertyType(@NonNull Object instance, @NonNull String field) { // in global.jelly, instance==descriptor return instance==this ? getGlobalPropertyType(field) : getPropertyType(field); } @@ -476,7 +476,7 @@ public void calcAutoCompleteSettings(String field, Map attributes * @throws AssertionError in case the field cannot be found * @since 1.492 */ - public @Nonnull PropertyType getPropertyTypeOrDie(@Nonnull Object instance, @Nonnull String field) { + public @NonNull PropertyType getPropertyTypeOrDie(@NonNull Object instance, @NonNull String field) { PropertyType propertyType = getPropertyType(instance, field); if (propertyType != null) { return propertyType; @@ -571,7 +571,7 @@ public T newInstance(StaplerRequest req) throws FormException { * Signals a problem in the submitted form. * @since 1.145 */ - public T newInstance(@Nullable StaplerRequest req, @Nonnull JSONObject formData) throws FormException { + public T newInstance(@Nullable StaplerRequest req, @NonNull JSONObject formData) throws FormException { try { Method m = getClass().getMethod("newInstance", StaplerRequest.class); @@ -828,7 +828,7 @@ public String getGlobalConfigPage() { * * @since 2.0, used to be in {@link GlobalConfiguration} before that. */ - public @Nonnull GlobalConfigurationCategory getCategory() { + public @NonNull GlobalConfigurationCategory getCategory() { return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Unclassified.class); } @@ -841,7 +841,7 @@ public String getGlobalConfigPage() { * @return Permission required to globally configure this descriptor. * @since 2.222 */ - public @Nonnull + public @NonNull Permission getRequiredGlobalConfigPagePermission() { return Jenkins.ADMINISTER; } diff --git a/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java b/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java index ef099a64dc77..89e8d1b7baab 100644 --- a/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java +++ b/core/src/main/java/hudson/model/DescriptorVisibilityFilter.java @@ -9,8 +9,8 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.ExtensionFilter; import jenkins.util.SystemProperties; @@ -37,7 +37,7 @@ public abstract class DescriptorVisibilityFilter implements ExtensionPoint { * the descriptor is not shown. * @since 2.12 */ - public boolean filterType(@Nonnull Class contextClass, @Nonnull Descriptor descriptor) { + public boolean filterType(@NonNull Class contextClass, @NonNull Descriptor descriptor) { return true; } @@ -57,7 +57,7 @@ public boolean filterType(@Nonnull Class contextClass, @Nonnull Descriptor de * If any of the installed {@link DescriptorVisibilityFilter} returns false, * the descriptor is not shown. */ - public abstract boolean filter(@CheckForNull Object context, @Nonnull Descriptor descriptor); + public abstract boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor); public static ExtensionList all() { return ExtensionList.lookup(DescriptorVisibilityFilter.class); diff --git a/core/src/main/java/hudson/model/DirectlyModifiableView.java b/core/src/main/java/hudson/model/DirectlyModifiableView.java index b799d2bd9e97..e12c34fa11cb 100644 --- a/core/src/main/java/hudson/model/DirectlyModifiableView.java +++ b/core/src/main/java/hudson/model/DirectlyModifiableView.java @@ -26,7 +26,7 @@ import java.io.IOException; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import org.kohsuke.stapler.HttpResponse; @@ -48,7 +48,7 @@ public interface DirectlyModifiableView { * @throws IOException Removal failed. * @throws IllegalArgumentException View rejected to remove an item. */ - boolean remove(@Nonnull TopLevelItem item) throws IOException, IllegalArgumentException; + boolean remove(@NonNull TopLevelItem item) throws IOException, IllegalArgumentException; /** * Add item to this view. @@ -56,7 +56,7 @@ public interface DirectlyModifiableView { * @throws IOException Adding failed. * @throws IllegalArgumentException View rejected to add an item. */ - void add(@Nonnull TopLevelItem item) throws IOException, IllegalArgumentException; + void add(@NonNull TopLevelItem item) throws IOException, IllegalArgumentException; /** * Handle addJobToView web method. diff --git a/core/src/main/java/hudson/model/EnvironmentContributingAction.java b/core/src/main/java/hudson/model/EnvironmentContributingAction.java index 03ad23fb351a..1eed758f725d 100644 --- a/core/src/main/java/hudson/model/EnvironmentContributingAction.java +++ b/core/src/main/java/hudson/model/EnvironmentContributingAction.java @@ -31,7 +31,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.ProtectedExternally; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * {@link Action} that contributes environment variables during a build. @@ -58,7 +58,7 @@ public interface EnvironmentContributingAction extends Action { * Environment variables should be added to this map. * @since 2.76 */ - default void buildEnvironment(@Nonnull Run run, @Nonnull EnvVars env) { + default void buildEnvironment(@NonNull Run run, @NonNull EnvVars env) { if (run instanceof AbstractBuild && Util.isOverridden(EnvironmentContributingAction.class, getClass(), "buildEnvVars", AbstractBuild.class, EnvVars.class)) { diff --git a/core/src/main/java/hudson/model/EnvironmentContributor.java b/core/src/main/java/hudson/model/EnvironmentContributor.java index 591d67cbef20..0a4c1ba1adf8 100644 --- a/core/src/main/java/hudson/model/EnvironmentContributor.java +++ b/core/src/main/java/hudson/model/EnvironmentContributor.java @@ -30,7 +30,7 @@ import hudson.scm.SCM; import java.io.IOException; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Contributes environment variables to builds. @@ -85,7 +85,7 @@ public abstract class EnvironmentContributor implements ExtensionPoint { * @param listener * Connected to the build console. Can be used to report errors. */ - public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull 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. @@ -107,7 +107,7 @@ public void buildEnvironmentFor(@Nonnull Run r, @Nonnull EnvVars envs, @Nonnull * Connected to the build console. Can be used to report errors. * @since 1.527 */ - public void buildEnvironmentFor(@Nonnull Job j, @Nonnull EnvVars envs, @Nonnull 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. diff --git a/core/src/main/java/hudson/model/Executor.java b/core/src/main/java/hudson/model/Executor.java index e168724088ce..2c6e66414ba9 100644 --- a/core/src/main/java/hudson/model/Executor.java +++ b/core/src/main/java/hudson/model/Executor.java @@ -46,7 +46,7 @@ import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.concurrent.GuardedBy; +import net.jcip.annotations.GuardedBy; import javax.servlet.ServletException; import java.io.IOException; import java.io.PrintWriter; @@ -67,8 +67,8 @@ import hudson.security.AccessControlled; import java.util.Collection; import static java.util.logging.Level.*; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.queue.AsynchronousExecution; import jenkins.security.QueueItemAuthenticatorConfiguration; import jenkins.security.QueueItemAuthenticatorDescriptor; @@ -85,7 +85,7 @@ */ @ExportedBean public class Executor extends Thread implements ModelObject { - protected final @Nonnull Computer owner; + protected final @NonNull Computer owner; private final Queue queue; private final ReadWriteLock lock = new ReentrantReadWriteLock(); private static final int DEFAULT_ESTIMATED_DURATION = -1; @@ -142,7 +142,7 @@ public class Executor extends Thread implements ModelObject { @GuardedBy("lock") private final List causes = new Vector<>(); - public Executor(@Nonnull Computer owner, int n) { + public Executor(@NonNull Computer owner, int n) { super("Executor #"+n+" for "+owner.getDisplayName()); this.owner = owner; this.queue = Jenkins.get().getQueue(); @@ -534,7 +534,7 @@ public Queue.Executable getCurrentExecutableForApi() { * @return Unmodifiable collection of causes of interruption. * @since 1.617 */ - public @Nonnull Collection getCausesOfInterruption() { + public @NonNull Collection getCausesOfInterruption() { return Collections.unmodifiableCollection(causes); } @@ -897,7 +897,7 @@ public boolean hasStopPermission() { } } - public @Nonnull Computer getOwner() { + public @NonNull Computer getOwner() { return owner; } diff --git a/core/src/main/java/hudson/model/Failure.java b/core/src/main/java/hudson/model/Failure.java index 4fb00809f023..53f8721311dc 100644 --- a/core/src/main/java/hudson/model/Failure.java +++ b/core/src/main/java/hudson/model/Failure.java @@ -28,7 +28,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.ServletException; import java.io.IOException; diff --git a/core/src/main/java/hudson/model/Fingerprint.java b/core/src/main/java/hudson/model/Fingerprint.java index af0e556c9ae6..e00c857244fb 100644 --- a/core/src/main/java/hudson/model/Fingerprint.java +++ b/core/src/main/java/hudson/model/Fingerprint.java @@ -71,8 +71,8 @@ import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.acegisecurity.AccessDeniedException; import org.acegisecurity.Authentication; import org.xmlpull.v1.XmlPullParserException; @@ -112,7 +112,7 @@ public BuildPtr(Run run) { * @return A name of the job */ @Exported - @Nonnull + @NonNull public String getName() { return name; } @@ -159,7 +159,7 @@ public Job getJob() { * @return A build number */ @Exported - @Nonnull + @NonNull public int getNumber() { return number; } @@ -851,7 +851,7 @@ private void locationChanged(Item item, String oldName, String newName) { /** * Time when the fingerprint has been captured. */ - private final @Nonnull Date timestamp; + private final @NonNull Date timestamp; /** * Null if this fingerprint is for a file that's @@ -875,12 +875,12 @@ private void locationChanged(Item item, String oldName, String newName) { */ private transient volatile List transientFacets = null; - public Fingerprint(@CheckForNull Run build, @Nonnull String fileName, @Nonnull byte[] md5sum) throws IOException { + public Fingerprint(@CheckForNull Run build, @NonNull String fileName, @NonNull byte[] md5sum) throws IOException { this(build==null ? null : new BuildPtr(build), fileName, md5sum); save(); } - Fingerprint(@CheckForNull BuildPtr original, @Nonnull String fileName, @Nonnull byte[] md5sum) { + Fingerprint(@CheckForNull BuildPtr original, @NonNull String fileName, @NonNull byte[] md5sum) { this.original = original; this.md5sum = md5sum; this.fileName = fileName; @@ -907,7 +907,7 @@ public Fingerprint(@CheckForNull Run build, @Nonnull String fileName, @Nonnull b return null; } - public @Nonnull String getDisplayName() { + public @NonNull String getDisplayName() { return fileName; } @@ -915,7 +915,7 @@ public Fingerprint(@CheckForNull Run build, @Nonnull String fileName, @Nonnull b * The file name (like "foo.jar" without path). */ @Exported - public @Nonnull String getFileName() { + public @NonNull String getFileName() { return fileName; } @@ -923,7 +923,7 @@ public Fingerprint(@CheckForNull Run build, @Nonnull String fileName, @Nonnull b * Gets the MD5 hash string. */ @Exported(name="hash") - public @Nonnull String getHashString() { + public @NonNull String getHashString() { return Util.toHexString(md5sum); } @@ -931,7 +931,7 @@ public Fingerprint(@CheckForNull Run build, @Nonnull String fileName, @Nonnull b * Gets the timestamp when this record is created. */ @Exported - public @Nonnull Date getTimestamp() { + public @NonNull Date getTimestamp() { return timestamp; } @@ -941,7 +941,7 @@ public Fingerprint(@CheckForNull Run build, @Nonnull String fileName, @Nonnull b * @return * string like "3 minutes" "1 day" etc. */ - public @Nonnull String getTimestampString() { + public @NonNull String getTimestampString() { long duration = System.currentTimeMillis()-timestamp.getTime(); return Util.getTimeSpanString(duration); } @@ -953,7 +953,7 @@ public Fingerprint(@CheckForNull Run build, @Nonnull String fileName, @Nonnull b * These builds of this job has used this file. * @return may be empty but not null. */ - public @Nonnull RangeSet getRangeSet(String jobFullName) { + public @NonNull RangeSet getRangeSet(String jobFullName) { RangeSet r = usages.get(jobFullName); if(r==null) r = new RangeSet(); return r; @@ -966,7 +966,7 @@ public RangeSet getRangeSet(Job job) { /** * Gets the sorted list of job names where this jar is used. */ - public @Nonnull List getJobs() { + public @NonNull List getJobs() { List r = new ArrayList<>(usages.keySet()); Collections.sort(r); return r; @@ -991,7 +991,7 @@ public RangeItem(String name, RangeSet ranges) { // this is for remote API @Exported(name="usage") - public @Nonnull List _getUsages() { + public @NonNull List _getUsages() { List r = new ArrayList<>(); final Jenkins instance = Jenkins.get(); for (Entry e : usages.entrySet()) { @@ -1007,7 +1007,7 @@ public RangeItem(String name, RangeSet ranges) { * @deprecated Use {@link #addFor(hudson.model.Run)} */ @Deprecated - public synchronized void add(@Nonnull AbstractBuild b) throws IOException { + public synchronized void add(@NonNull AbstractBuild b) throws IOException { addFor(b); } @@ -1016,14 +1016,14 @@ public synchronized void add(@Nonnull AbstractBuild b) throws IOException { * @param b {@link Run} to be referenced in {@link #usages} * @since 1.577 */ - public synchronized void addFor(@Nonnull Run b) throws IOException { + public synchronized void addFor(@NonNull Run b) throws IOException { add(b.getParent().getFullName(), b.getNumber()); } /** * Records that a build of a job has used this file. */ - public synchronized void add(@Nonnull String jobFullName, int n) throws IOException { + public synchronized void add(@NonNull String jobFullName, int n) throws IOException { addWithoutSaving(jobFullName, n); save(); } @@ -1036,7 +1036,7 @@ protected Object readResolve() { return this; } - void addWithoutSaving(@Nonnull String jobFullName, int n) { + void addWithoutSaving(@NonNull String jobFullName, int n) { synchronized(usages) { // TODO why not synchronized (this) like some, though not all, other accesses? RangeSet r = usages.get(jobFullName); if(r==null) { @@ -1155,7 +1155,7 @@ public synchronized boolean trim() throws IOException { * * @since 1.421 */ - public @Nonnull Collection getFacets() { + public @NonNull Collection getFacets() { if (transientFacets==null) { List transientFacets = new ArrayList<>(); for (TransientFingerprintFacetFactory fff : TransientFingerprintFacetFactory.all()) { @@ -1197,7 +1197,7 @@ public int size() { * Sorts {@link FingerprintFacet}s by their timestamps. * @return Sorted list of {@link FingerprintFacet}s */ - public @Nonnull Collection getSortedFacets() { + public @NonNull Collection getSortedFacets() { List r = new ArrayList<>(getFacets()); r.sort(new Comparator() { public int compare(FingerprintFacet o1, FingerprintFacet o2) { @@ -1226,7 +1226,7 @@ public int compare(FingerprintFacet o1, FingerprintFacet o2) { /** * Returns the actions contributed from {@link #getFacets()} */ - public @Nonnull List getActions() { + public @NonNull List getActions() { List r = new ArrayList<>(); for (FingerprintFacet ff : getFacets()) ff.createActions(r); @@ -1350,14 +1350,14 @@ public Api getApi() { /** * The file we save our configuration. */ - private static @Nonnull XmlFile getConfigFile(@Nonnull File file) { + private static @NonNull XmlFile getConfigFile(@NonNull File file) { return new XmlFile(XSTREAM,file); } /** * Determines the file name from md5sum. */ - private static @Nonnull File getFingerprintFile(@Nonnull byte[] md5sum) { + private static @NonNull File getFingerprintFile(@NonNull byte[] md5sum) { assert md5sum.length==16; return new File( Jenkins.get().getRootDir(), "fingerprints/"+ Util.toHexString(md5sum,0,1)+'/'+Util.toHexString(md5sum,1,1)+'/'+Util.toHexString(md5sum,2,md5sum.length-2)+".xml"); @@ -1368,10 +1368,10 @@ public Api getApi() { * @return Loaded {@link Fingerprint}. Null if the config file does not exist or * malformed. */ - /*package*/ static @CheckForNull Fingerprint load(@Nonnull byte[] md5sum) throws IOException { + /*package*/ static @CheckForNull Fingerprint load(@NonNull byte[] md5sum) throws IOException { return load(getFingerprintFile(md5sum)); } - /*package*/ static @CheckForNull Fingerprint load(@Nonnull File file) throws IOException { + /*package*/ static @CheckForNull Fingerprint load(@NonNull File file) throws IOException { XmlFile configFile = getConfigFile(file); if(!configFile.exists()) return null; @@ -1438,7 +1438,7 @@ private static String messageOfParseException(Throwable t) { * @param fullName Full name of the job * @return {@code true} if the user can discover the item */ - private static boolean canDiscoverItem(@Nonnull final String fullName) { + private static boolean canDiscoverItem(@NonNull final String fullName) { final Jenkins jenkins = Jenkins.get(); // Fast check to avoid security context switches @@ -1490,7 +1490,7 @@ private static boolean canDiscoverItem(@Nonnull final String fullName) { * @return the XStream instance * @since 1.655 */ - @Nonnull + @NonNull public static XStream2 getXStream() { return XSTREAM; } diff --git a/core/src/main/java/hudson/model/FingerprintMap.java b/core/src/main/java/hudson/model/FingerprintMap.java index 2727d22174a6..16e9bd724182 100644 --- a/core/src/main/java/hudson/model/FingerprintMap.java +++ b/core/src/main/java/hudson/model/FingerprintMap.java @@ -30,8 +30,8 @@ import java.io.File; import java.io.IOException; import java.util.Locale; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Cache of {@link Fingerprint}s. @@ -60,15 +60,15 @@ public boolean isReady() { * an owner-less build. * @throws IOException Loading error */ - public @Nonnull Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @Nonnull String fileName, @Nonnull byte[] md5sum) throws IOException { + public @NonNull Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @NonNull String fileName, @NonNull byte[] md5sum) throws IOException { return getOrCreate(build,fileName, Util.toHexString(md5sum)); } - public @Nonnull Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @Nonnull String fileName, @Nonnull String md5sum) throws IOException { + public @NonNull Fingerprint getOrCreate(@CheckForNull AbstractBuild build, @NonNull String fileName, @NonNull String md5sum) throws IOException { return super.getOrCreate(md5sum, new FingerprintParams(build,fileName)); } - public @Nonnull Fingerprint getOrCreate(@CheckForNull Run build, @Nonnull String fileName, @Nonnull String md5sum) throws IOException { + public @NonNull Fingerprint getOrCreate(@CheckForNull Run build, @NonNull String fileName, @NonNull String md5sum) throws IOException { return super.getOrCreate(md5sum, new FingerprintParams(build,fileName)); } @@ -89,11 +89,11 @@ private byte[] toByteArray(String md5sum) { return data; } - protected @Nonnull Fingerprint create(@Nonnull String md5sum, @Nonnull FingerprintParams createParams) throws IOException { + protected @NonNull Fingerprint create(@NonNull String md5sum, @NonNull FingerprintParams createParams) throws IOException { return new Fingerprint(createParams.build, createParams.fileName, toByteArray(md5sum)); } - protected @CheckForNull Fingerprint load(@Nonnull String key) throws IOException { + protected @CheckForNull Fingerprint load(@NonNull String key) throws IOException { return Fingerprint.load(toByteArray(key)); } @@ -104,7 +104,7 @@ static class FingerprintParams { final @CheckForNull Run build; final String fileName; - public FingerprintParams(@CheckForNull Run build, @Nonnull String fileName) { + public FingerprintParams(@CheckForNull Run build, @NonNull String fileName) { this.build = build; this.fileName = fileName; diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index b20ddd349f59..ecc8ba57dbd5 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -51,7 +51,7 @@ import java.util.List; import static hudson.Util.fixEmpty; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; public class Hudson extends Jenkins { diff --git a/core/src/main/java/hudson/model/Item.java b/core/src/main/java/hudson/model/Item.java index d4d0a6dcc0d5..57a59f95c1a7 100644 --- a/core/src/main/java/hudson/model/Item.java +++ b/core/src/main/java/hudson/model/Item.java @@ -42,8 +42,8 @@ import hudson.security.AccessControlled; import hudson.util.Secret; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Basic configuration unit in Hudson. @@ -158,7 +158,7 @@ default String getRelativeNameFrom(@CheckForNull ItemGroup g) { * @since 1.419 */ @Nullable - default String getRelativeNameFrom(@Nonnull Item item) { + default String getRelativeNameFrom(@NonNull Item item) { return getRelativeNameFrom(item.getParent()); } diff --git a/core/src/main/java/hudson/model/ItemGroup.java b/core/src/main/java/hudson/model/ItemGroup.java index 0bd366a968ea..df5b7a8f1b6d 100644 --- a/core/src/main/java/hudson/model/ItemGroup.java +++ b/core/src/main/java/hudson/model/ItemGroup.java @@ -32,7 +32,7 @@ import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.acegisecurity.AccessDeniedException; /** diff --git a/core/src/main/java/hudson/model/Items.java b/core/src/main/java/hudson/model/Items.java index 4d1fbd374dbc..298d30235845 100644 --- a/core/src/main/java/hudson/model/Items.java +++ b/core/src/main/java/hudson/model/Items.java @@ -48,8 +48,8 @@ import java.util.Stack; import java.util.StringTokenizer; import java.util.function.Predicate; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.DirectlyModifiableTopLevelItemGroup; import jenkins.model.Jenkins; import org.acegisecurity.Authentication; @@ -222,7 +222,7 @@ public static List fromNameList(String list, Class type) /** * Does the opposite of {@link #toNameList(Collection)}. */ - public static List fromNameList(ItemGroup context, @Nonnull String list, @Nonnull Class type) { + public static List fromNameList(ItemGroup context, @NonNull String list, @NonNull Class type) { final Jenkins jenkins = Jenkins.get(); List r = new ArrayList<>(); @@ -677,7 +677,7 @@ public T next() { * @throws IllegalArgumentException if there is already something there, which you were supposed to know about * @throws Failure if there is already something there but you should not be told details */ - static void verifyItemDoesNotAlreadyExist(@Nonnull ItemGroup parent, @Nonnull String newName, @CheckForNull Item variant) throws IllegalArgumentException, Failure { + static void verifyItemDoesNotAlreadyExist(@NonNull ItemGroup parent, @NonNull String newName, @CheckForNull Item variant) throws IllegalArgumentException, Failure { Item existing; try (ACLContext ctxt = ACL.as(ACL.SYSTEM)) { existing = parent.getItem(newName); diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index caddc5ca607b..4f695371f273 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -77,8 +77,8 @@ import java.util.SortedMap; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import jenkins.model.BuildDiscarder; import jenkins.model.BuildDiscarderProperty; @@ -375,7 +375,7 @@ public EnvVars getCharacteristicEnvVars() { * 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.) */ - public @Nonnull EnvVars getEnvironment(@CheckForNull Node node, @Nonnull TaskListener listener) throws IOException, InterruptedException { + public @NonNull EnvVars getEnvironment(@CheckForNull Node node, @NonNull TaskListener listener) throws IOException, InterruptedException { EnvVars env = new EnvVars(); if (node != null) { diff --git a/core/src/main/java/hudson/model/JobProperty.java b/core/src/main/java/hudson/model/JobProperty.java index 9ab16848b8a0..5417081e5ba3 100644 --- a/core/src/main/java/hudson/model/JobProperty.java +++ b/core/src/main/java/hudson/model/JobProperty.java @@ -42,7 +42,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.export.ExportedBean; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Extensible property of {@link Job}. @@ -131,7 +131,7 @@ public Action getJobAction(J job) { * @see ProminentProjectAction * @see PermalinkProjectAction */ - @Nonnull + @NonNull public Collection getJobActions(J job) { // delegate to getJobAction (singular) for backward compatible behavior Action a = getJobAction(job); @@ -170,7 +170,7 @@ public final Action getProjectAction(AbstractProject project) { return getJobAction((J)project); } - @Nonnull + @NonNull public final Collection getProjectActions(AbstractProject project) { return getJobActions((J)project); } diff --git a/core/src/main/java/hudson/model/Label.java b/core/src/main/java/hudson/model/Label.java index f5fe9b19a6b8..8d3bcf70fa5c 100644 --- a/core/src/main/java/hudson/model/Label.java +++ b/core/src/main/java/hudson/model/Label.java @@ -75,7 +75,7 @@ import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Group of {@link Node}s. @@ -89,19 +89,19 @@ public abstract class Label extends Actionable implements Comparable

* This status code is used in a multi-stage build (like maven2) * where a problem in earlier stage prevented later stages from building. */ - public static final @Nonnull Result NOT_BUILT = new Result("NOT_BUILT",BallColor.NOTBUILT,3,false); + public static final @NonNull Result NOT_BUILT = new Result("NOT_BUILT",BallColor.NOTBUILT,3,false); /** * The build was manually aborted. * * If you are catching {@link InterruptedException} and interpreting it as {@link #ABORTED}, * you should check {@link Executor#abortResult()} instead (starting 1.417.) */ - public static final @Nonnull Result ABORTED = new Result("ABORTED",BallColor.ABORTED,4,false); + public static final @NonNull Result ABORTED = new Result("ABORTED",BallColor.ABORTED,4,false); - private final @Nonnull String name; + private final @NonNull String name; /** * Bigger numbers are worse. */ - public final @Nonnegative int ordinal; + public final /* @java.annotation.Nonnegative */ int ordinal; /** * Default ball color for this status. */ - public final @Nonnull BallColor color; + public final @NonNull BallColor color; /** * Is this a complete build - i.e. did it run to the end (not aborted)? @@ -97,7 +96,7 @@ public final class Result implements Serializable, CustomExportedBean { */ public final boolean completeBuild; - private Result(@Nonnull String name, @Nonnull BallColor color, @Nonnegative int ordinal, boolean complete) { + private Result(@NonNull String name, @NonNull BallColor color, /*@java.annotation.Nonnegative */int ordinal, boolean complete) { this.name = name; this.color = color; this.ordinal = ordinal; @@ -107,26 +106,26 @@ private Result(@Nonnull String name, @Nonnull BallColor color, @Nonnegative int /** * Combines two {@link Result}s and returns the worse one. */ - public @Nonnull Result combine(@Nonnull Result that) { + public @NonNull Result combine(@NonNull Result that) { if(this.ordinal < that.ordinal) return that; else return this; } - public boolean isWorseThan(@Nonnull Result that) { + public boolean isWorseThan(@NonNull Result that) { return this.ordinal > that.ordinal; } - public boolean isWorseOrEqualTo(@Nonnull Result that) { + public boolean isWorseOrEqualTo(@NonNull Result that) { return this.ordinal >= that.ordinal; } - public boolean isBetterThan(@Nonnull Result that) { + public boolean isBetterThan(@NonNull Result that) { return this.ordinal < that.ordinal; } - public boolean isBetterOrEqualTo(@Nonnull Result that) { + public boolean isBetterOrEqualTo(@NonNull Result that) { return this.ordinal <= that.ordinal; } @@ -139,22 +138,22 @@ public boolean isCompleteBuild() { } @Override - public @Nonnull String toString() { + public @NonNull String toString() { return name; } - public @Nonnull String toExportedObject() { + public @NonNull String toExportedObject() { return name; } - public static @Nonnull Result fromString(@Nonnull String s) { + public static @NonNull Result fromString(@NonNull String s) { for (Result r : all) if (s.equalsIgnoreCase(r.name)) return r; return FAILURE; } - private static @Nonnull List getNames() { + private static @NonNull List getNames() { List l = new ArrayList<>(); for (Result r : all) l.add(r.name); diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index 8d32b1ebafb7..6943e765e610 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -100,8 +100,8 @@ import static java.util.logging.Level.*; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import jenkins.model.ArtifactManager; @@ -166,7 +166,7 @@ public abstract class Run ,RunT extends Run getTransientActions() { */ @SuppressWarnings("deprecation") @Override - public void addAction(@Nonnull Action a) { + public void addAction(@NonNull Action a) { super.addAction(a); if (a instanceof RunAction2) { ((RunAction2) a).onAttached(this); @@ -429,7 +429,7 @@ public void addAction(@Nonnull Action a) { * Obtains 'this' in a more type safe signature. */ @SuppressWarnings({"unchecked"}) - protected @Nonnull RunT _this() { + protected @NonNull RunT _this() { return (RunT)this; } @@ -437,7 +437,7 @@ public void addAction(@Nonnull Action a) { * Ordering based on build numbers. * If numbers are equal order based on names of parent projects. */ - public int compareTo(@Nonnull RunT that) { + public int compareTo(@NonNull RunT that) { final int res = this.number - that.number; if (res == 0) return this.getParent().getFullName().compareTo(that.getParent().getFullName()); @@ -488,7 +488,7 @@ public void setQueueId(long queueId) { * @param r the proposed new result * @throws IllegalStateException if the build has not yet started, is in post-production, or is complete */ - public void setResult(@Nonnull Result r) { + public void setResult(@NonNull Result r) { if (state != State.BUILDING) { throw new IllegalStateException("cannot change build result while in " + state); } @@ -503,7 +503,7 @@ public void setResult(@Nonnull Result r) { /** * Gets the subset of {@link #getActions()} that consists of {@link BuildBadgeAction}s. */ - public @Nonnull List getBadgeActions() { + public @NonNull List getBadgeActions() { List r = getActions(BuildBadgeAction.class); if(isKeepLog()) { r = new ArrayList<>(r); @@ -572,7 +572,7 @@ public boolean isLogUpdated() { * @return never null. * @since 1.257 */ - public final @Nonnull Charset getCharset() { + public final @NonNull Charset getCharset() { if(charset==null) return Charset.defaultCharset(); return Charset.forName(charset); } @@ -588,7 +588,7 @@ public boolean isLogUpdated() { * can be empty but never null. read-only. * @since 1.321 */ - public @Nonnull List getCauses() { + public @NonNull List getCauses() { CauseAction a = getAction(CauseAction.class); if (a==null) return Collections.emptyList(); return Collections.unmodifiableList(a.getCauses()); @@ -629,7 +629,7 @@ public final boolean isKeepLog() { /** * The project this build is for. */ - public @Nonnull JobT getParent() { + public @NonNull JobT getParent() { return project; } @@ -639,7 +639,7 @@ public final boolean isKeepLog() { * @see #getStartTimeInMillis() */ @Exported - public @Nonnull Calendar getTimestamp() { + public @NonNull Calendar getTimestamp() { GregorianCalendar c = new GregorianCalendar(); c.setTimeInMillis(timestamp); return c; @@ -648,7 +648,7 @@ public final boolean isKeepLog() { /** * Same as {@link #getTimestamp()} but in a different type. */ - public final @Nonnull Date getTime() { + public final @NonNull Date getTime() { return new Date(timestamp); } @@ -746,7 +746,7 @@ public String getDescription() { * @return * string like "3 minutes" "1 day" etc. */ - public @Nonnull String getTimestampString() { + public @NonNull String getTimestampString() { long duration = new GregorianCalendar().getTimeInMillis()-timestamp; return Util.getTimeSpanString(duration); } @@ -754,14 +754,14 @@ public String getDescription() { /** * Returns the timestamp formatted in xs:dateTime. */ - public @Nonnull String getTimestampString2() { + public @NonNull String getTimestampString2() { return Util.XS_DATETIME_FORMATTER.format(new Date(timestamp)); } /** * Gets the string that says how long the build took to run. */ - public @Nonnull String getDurationString() { + public @NonNull String getDurationString() { if (hasntStartedYet()) { return Messages.Run_NotStartedYet(); } else if (isBuilding()) { @@ -782,7 +782,7 @@ public long getDuration() { /** * Gets the icon color for display. */ - public @Nonnull BallColor getIconColor() { + public @NonNull BallColor getIconColor() { if(!isBuilding()) { // already built return getResult().color; @@ -849,7 +849,7 @@ public int getNumber() { * @see jenkins.model.lazy.LazyBuildMixIn.RunMixIn#createReference * @since 1.556 */ - protected @Nonnull BuildReference createReference() { + protected @NonNull BuildReference createReference() { return new BuildReference<>(getId(), _this()); } @@ -976,7 +976,7 @@ protected void dropLinks() { * if not enough builds satisfying the threshold have been found. Never null. * @since 1.383 */ - public @Nonnull List getPreviousBuildsOverThreshold(int numberOfBuilds, @Nonnull Result threshold) { + public @NonNull List getPreviousBuildsOverThreshold(int numberOfBuilds, @NonNull Result threshold) { RunT r = getPreviousBuild(); if (r != null) { return r.getBuildsOverThreshold(numberOfBuilds, threshold); @@ -994,7 +994,7 @@ protected void dropLinks() { * if not enough builds satisfying the threshold have been found. Never null. * @since 2.202 */ - protected @Nonnull List getBuildsOverThreshold(int numberOfBuilds, @Nonnull Result threshold) { + protected @NonNull List getBuildsOverThreshold(int numberOfBuilds, @NonNull Result threshold) { List builds = new ArrayList<>(numberOfBuilds); RunT r = _this(); @@ -1024,7 +1024,7 @@ protected void dropLinks() { */ // I really messed this up. I'm hoping to fix this some time // it shouldn't have trailing '/', and instead it should have leading '/' - public @Nonnull String getUrl() { + public @NonNull String getUrl() { // RUN may be accessed using permalinks, as "/lastSuccessful" or other, so try to retrieve this base URL // looking for "this" in the current request ancestors @@ -1051,11 +1051,11 @@ protected void dropLinks() { */ @Exported(visibility=2,name="url") @Deprecated - public final @Nonnull String getAbsoluteUrl() { + public final @NonNull String getAbsoluteUrl() { return project.getAbsoluteUrl()+getNumber()+'/'; } - public final @Nonnull String getSearchUrl() { + public final @NonNull String getSearchUrl() { return getNumber()+"/"; } @@ -1064,7 +1064,7 @@ protected void dropLinks() { * Usually the decimal form of {@link #number}, but may be a formatted timestamp for historical builds. */ @Exported - public @Nonnull String getId() { + public @NonNull String getId() { return id != null ? id : Integer.toString(number); } @@ -1074,7 +1074,7 @@ protected void dropLinks() { * @return Root directory of this {@link Run} on the master. Never null */ @Override - public @Nonnull File getRootDir() { + public @NonNull File getRootDir() { return new File(project.getBuildDir(), Integer.toString(number)); } @@ -1088,7 +1088,7 @@ protected void dropLinks() { * @return an appropriate artifact manager * @since 1.532 */ - public final @Nonnull ArtifactManager getArtifactManager() { + public final @NonNull ArtifactManager getArtifactManager() { return artifactManager != null ? artifactManager : new StandardArtifactManager(this); } @@ -1104,7 +1104,7 @@ protected void dropLinks() { * @throws IOException if a custom manager was selected but the selection could not be saved * @since 1.532 */ - public final synchronized @Nonnull ArtifactManager pickArtifactManager() throws IOException { + public final synchronized @NonNull ArtifactManager pickArtifactManager() throws IOException { if (artifactManager != null) { return artifactManager; } else { @@ -1134,7 +1134,7 @@ public File getArtifactsDir() { * @return The list can be empty but never null */ @Exported - public @Nonnull List getArtifacts() { + public @NonNull List getArtifacts() { return getArtifactsUpTo(Integer.MAX_VALUE); } @@ -1142,7 +1142,7 @@ public File getArtifactsDir() { * Gets the first N artifacts. * @return The list can be empty but never null */ - public @Nonnull List getArtifactsUpTo(int artifactsNumber) { + public @NonNull List getArtifactsUpTo(int artifactsNumber) { SerializableArtifactList sal; VirtualFile root = getArtifactManager().root(); try { @@ -1182,9 +1182,9 @@ public SerializableArtifactList call() throws IOException { } } - private static int addArtifacts(@Nonnull VirtualFile dir, - @Nonnull String path, @Nonnull String pathHref, - @Nonnull SerializableArtifactList r, @CheckForNull SerializableArtifact parent, int upTo) throws IOException { + private static int addArtifacts(@NonNull VirtualFile dir, + @NonNull String path, @NonNull String pathHref, + @NonNull SerializableArtifactList r, @CheckForNull SerializableArtifact parent, int upTo) throws IOException { VirtualFile[] kids = dir.list(); Arrays.sort(kids); @@ -1413,7 +1413,7 @@ public class Artifact { * @deprecated May not be meaningful with custom artifact managers. Use {@link ArtifactManager#root} plus {@link VirtualFile#child} with {@link #relativePath} instead. */ @Deprecated - public @Nonnull File getFile() { + public @NonNull File getFile() { return new File(getArtifactsDir(),relativePath); } @@ -1463,7 +1463,7 @@ public String toString() { * * @return The fingerprints */ - @Nonnull + @NonNull @Exported(name = "fingerprint", inline = true, visibility = -1) public Collection getBuildFingerprints() { FingerprintAction fingerprintAction = getAction(FingerprintAction.class); @@ -1479,7 +1479,7 @@ public Collection getBuildFingerprints() { * @deprecated Assumes file-based storage of the log, which is not necessarily the case for Pipelines after JEP-210. Use other methods giving various kinds of streams such as {@link Run#getLogReader()}, {@link Run#getLogInputStream()}, or {@link Run#getLogText()}. */ @Deprecated - public @Nonnull File getLogFile() { + public @NonNull File getLogFile() { File rawF = new File(getRootDir(), "log"); if (rawF.isFile()) { return rawF; @@ -1501,7 +1501,7 @@ public Collection getBuildFingerprints() { * If the log file does not exist, the error message will be returned to the output. * @since 1.349 */ - public @Nonnull InputStream getLogInputStream() throws IOException { + public @NonNull InputStream getLogInputStream() throws IOException { File logFile = getLogFile(); if (logFile.exists() ) { @@ -1522,7 +1522,7 @@ public Collection getBuildFingerprints() { return new ByteArrayInputStream(charset != null ? message.getBytes(charset) : message.getBytes()); } - public @Nonnull Reader getLogReader() throws IOException { + public @NonNull Reader getLogReader() throws IOException { if (charset==null) return new InputStreamReader(getLogInputStream()); else return new InputStreamReader(getLogInputStream(),charset); } @@ -1532,7 +1532,7 @@ public Collection getBuildFingerprints() { * * @since 1.349 */ - public void writeLogTo(long offset, @Nonnull XMLOutput out) throws IOException { + public void writeLogTo(long offset, @NonNull XMLOutput out) throws IOException { getLogText().writeHtmlTo(offset, out.asWriter()); } @@ -1544,7 +1544,7 @@ public void writeLogTo(long offset, @Nonnull XMLOutput out) throws IOException { *

* The method does not close the {@link OutputStream}. */ - public void writeWholeLogTo(@Nonnull OutputStream out) throws IOException, InterruptedException { + public void writeWholeLogTo(@NonNull OutputStream out) throws IOException, InterruptedException { long pos = 0; AnnotatedLargeText logText; logText = getLogText(); @@ -1563,12 +1563,12 @@ public void writeWholeLogTo(@Nonnull OutputStream out) throws IOException, Inter * Used to URL-bind {@link AnnotatedLargeText}. * @return A {@link Run} log with annotations */ - public @Nonnull AnnotatedLargeText getLogText() { + public @NonNull AnnotatedLargeText getLogText() { return new AnnotatedLargeText(getLogFile(),getCharset(),!isLogUpdated(),this); } @Override - protected @Nonnull SearchIndexBuilder makeSearchIndex() { + protected @NonNull SearchIndexBuilder makeSearchIndex() { SearchIndexBuilder builder = super.makeSearchIndex() .add("console") .add("changes"); @@ -1579,7 +1579,7 @@ public void writeWholeLogTo(@Nonnull OutputStream out) throws IOException, Inter return builder; } - public @Nonnull Api getApi() { + public @NonNull Api getApi() { return new Api(this); } @@ -1671,7 +1671,7 @@ private void removeRunFromParent() { /** * @see CheckPoint#report() */ - /*package*/ static void reportCheckpoint(@Nonnull CheckPoint id) { + /*package*/ static void reportCheckpoint(@NonNull CheckPoint id) { Run.RunExecution exec = RunnerStack.INSTANCE.peek(); if (exec == null) { return; @@ -1682,7 +1682,7 @@ private void removeRunFromParent() { /** * @see CheckPoint#block() */ - /*package*/ static void waitForCheckpoint(@Nonnull CheckPoint id, @CheckForNull BuildListener listener, @CheckForNull String waiter) throws InterruptedException { + /*package*/ static void waitForCheckpoint(@NonNull CheckPoint id, @CheckForNull BuildListener listener, @CheckForNull String waiter) throws InterruptedException { while(true) { Run.RunExecution exec = RunnerStack.INSTANCE.peek(); if (exec == null) { @@ -1728,12 +1728,12 @@ private final class CheckpointSet { private boolean allDone; - protected synchronized void report(@Nonnull CheckPoint identifier) { + protected synchronized void report(@NonNull CheckPoint identifier) { checkpoints.add(identifier); notifyAll(); } - protected synchronized boolean waitForCheckPoint(@Nonnull CheckPoint identifier, @CheckForNull BuildListener listener, @CheckForNull String waiter) throws InterruptedException { + protected synchronized boolean waitForCheckPoint(@NonNull CheckPoint identifier, @CheckForNull BuildListener listener, @CheckForNull String waiter) throws InterruptedException { final Thread t = Thread.currentThread(); final String oldName = t.getName(); t.setName(oldName + " : waiting for " + identifier + " on " + getFullDisplayName() + " from " + waiter); @@ -1771,7 +1771,7 @@ private synchronized void allDone() { * @throws Exception * exception will be recorded and the build will be considered a failure. */ - public abstract @Nonnull Result run(@Nonnull BuildListener listener ) throws Exception, RunnerAbortedException; + public abstract @NonNull Result run(@NonNull BuildListener listener ) throws Exception, RunnerAbortedException; /** * Performs the post-build action. @@ -1783,7 +1783,7 @@ private synchronized void allDone() { * even if the build is successful, this build still won't be picked up * by {@link Job#getLastSuccessfulBuild()}. */ - public abstract void post(@Nonnull BuildListener listener ) throws Exception; + public abstract void post(@NonNull BuildListener listener ) throws Exception; /** * Performs final clean up action. @@ -1795,13 +1795,13 @@ private synchronized void allDone() { * Among other things, this is often a necessary pre-condition * before invoking other builds that depend on this build. */ - public abstract void cleanUp(@Nonnull BuildListener listener) throws Exception; + public abstract void cleanUp(@NonNull BuildListener listener) throws Exception; - public @Nonnull RunT getBuild() { + public @NonNull RunT getBuild() { return _this(); } - public @Nonnull JobT getProject() { + public @NonNull JobT getProject() { return _this().getParent(); } @@ -1811,7 +1811,7 @@ private synchronized void allDone() { * * @since 1.473 */ - public @Nonnull Map getAttributes() { + public @NonNull Map getAttributes() { return attributes; } } @@ -1830,11 +1830,11 @@ public static final class RunnerAbortedException extends RuntimeException { * Use {@link #execute(hudson.model.Run.RunExecution)} */ @Deprecated - protected final void run(@Nonnull Runner job) { + protected final void run(@NonNull Runner job) { execute(job); } - protected final void execute(@Nonnull RunExecution job) { + protected final void execute(@NonNull RunExecution job) { if(result!=null) return; // already built. @@ -1968,7 +1968,7 @@ private OutputStream createLogger() throws IOException { } } - private StreamBuildListener createBuildListener(@Nonnull RunExecution job, OutputStream logger, Charset charset) throws IOException, InterruptedException { + private StreamBuildListener createBuildListener(@NonNull RunExecution job, OutputStream logger, Charset charset) throws IOException, InterruptedException { RunT build = job.getBuild(); // Global log filters @@ -1991,12 +1991,12 @@ private StreamBuildListener createBuildListener(@Nonnull RunExecution job, Outpu * @deprecated After JENKINS-37862 this no longer does anything. */ @Deprecated - public final void updateSymlinks(@Nonnull TaskListener listener) throws InterruptedException {} + public final void updateSymlinks(@NonNull TaskListener listener) throws InterruptedException {} /** * Handles a fatal build problem (exception) that occurred during the build. */ - private void handleFatalBuildProblem(@Nonnull BuildListener listener, @Nonnull Throwable e) { + private void handleFatalBuildProblem(@NonNull BuildListener listener, @NonNull Throwable e) { if(listener!=null) { LOGGER.log(FINE, getDisplayName()+" failed to build",e); @@ -2051,7 +2051,7 @@ public synchronized void save() throws IOException { SaveableListener.fireOnChange(this, getDataFile()); } - private @Nonnull XmlFile getDataFile() { + private @NonNull XmlFile getDataFile() { return new XmlFile(XSTREAM,new File(getRootDir(),"build.xml")); } @@ -2076,7 +2076,7 @@ private Object readResolve() { * the whole log into memory unnecessarily. */ @Deprecated - public @Nonnull String getLog() throws IOException { + public @NonNull String getLog() throws IOException { return Util.loadFile(getLogFile(),getCharset()); } @@ -2089,7 +2089,7 @@ private Object readResolve() { * @return A list of log lines. Will have no more than maxLines elements. * @throws IOException If there is a problem reading the log file. */ - public @Nonnull List getLog(int maxLines) throws IOException { + public @NonNull List getLog(int maxLines) throws IOException { if (maxLines == 0) { return Collections.emptyList(); } @@ -2144,7 +2144,7 @@ public void doBuildStatus( StaplerRequest req, StaplerResponse rsp ) throws IOEx rsp.sendRedirect2(req.getContextPath()+"/images/48x48/"+getBuildStatusUrl()); } - public @Nonnull String getBuildStatusUrl() { + public @NonNull String getBuildStatusUrl() { return getIconColor().getImage(); } @@ -2176,7 +2176,7 @@ public static abstract class StatusSummarizer implements ExtensionPoint { * @param trend the result of {@link ResultTrend#getResultTrend(hudson.model.Run)} on {@code run} (precomputed for efficiency) * @return a summary, or null to fall back to other summarizers or built-in behavior */ - public abstract @CheckForNull Summary summarize(@Nonnull Run run, @Nonnull ResultTrend trend); + public abstract @CheckForNull Summary summarize(@NonNull Run run, @NonNull ResultTrend trend); } /** @@ -2184,7 +2184,7 @@ public static abstract class StatusSummarizer implements ExtensionPoint { * (especially in comparison with the previous build.) * @see StatusSummarizer */ - public @Nonnull Summary getBuildStatusSummary() { + public @NonNull Summary getBuildStatusSummary() { if (isBuilding()) { return new Summary(false, Messages.Run_Summary_Unknown()); } @@ -2233,7 +2233,7 @@ public static abstract class StatusSummarizer implements ExtensionPoint { * Serves the artifacts. * @throws AccessDeniedException Access denied */ - public @Nonnull DirectoryBrowserSupport doArtifact() { + public @NonNull DirectoryBrowserSupport doArtifact() { if(Functions.isArtifactsPermissionEnabled()) { checkPermission(ARTIFACTS); } @@ -2403,7 +2403,7 @@ public EnvVars getEnvironment() throws IOException, InterruptedException { * @return the map with the environmental variables. * @since 1.305 */ - public @Nonnull EnvVars getEnvironment(@Nonnull TaskListener listener) throws IOException, InterruptedException { + public @NonNull EnvVars getEnvironment(@NonNull TaskListener listener) throws IOException, InterruptedException { Computer c = Computer.currentComputer(); Node n = c==null ? null : c.getNode(); @@ -2427,7 +2427,7 @@ public EnvVars getEnvironment() throws IOException, InterruptedException { * Builds up the environment variable map that's sufficient to identify a process * as ours. This is used to kill run-away processes via {@link ProcessTree#killAll(Map)}. */ - public @Nonnull final EnvVars getCharacteristicEnvVars() { + public @NonNull final EnvVars getCharacteristicEnvVars() { EnvVars env = getParent().getCharacteristicEnvVars(); env.put("BUILD_NUMBER",String.valueOf(number)); env.put("BUILD_ID",getId()); @@ -2440,7 +2440,7 @@ public EnvVars getEnvironment() throws IOException, InterruptedException { * @return the {@link Job#getFullName}, then {@code #}, then {@link #getNumber} * @see #fromExternalizableId */ - public @Nonnull String getExternalizableId() { + public @NonNull String getExternalizableId() { return project.getFullName() + "#" + getNumber(); } @@ -2487,7 +2487,7 @@ public long getEstimatedDuration() { } @POST - public @Nonnull HttpResponse doConfigSubmit( StaplerRequest req ) throws IOException, ServletException, FormException { + public @NonNull HttpResponse doConfigSubmit( StaplerRequest req ) throws IOException, ServletException, FormException { checkPermission(UPDATE); try (BulkChange bc = new BulkChange(this)) { JSONObject json = req.getSubmittedForm(); @@ -2520,7 +2520,7 @@ protected void submit(JSONObject json) throws IOException { * Sort by date. Newer ones first. */ public static final Comparator ORDER_BY_DATE = new Comparator() { - public int compare(@Nonnull Run lhs, @Nonnull Run rhs) { + public int compare(@NonNull Run lhs, @NonNull Run rhs) { long lt = lhs.getTimeInMillis(); long rt = rhs.getTimeInMillis(); return Long.compare(rt, lt); diff --git a/core/src/main/java/hudson/model/RunParameterValue.java b/core/src/main/java/hudson/model/RunParameterValue.java index 71bc17012671..39e152666d18 100644 --- a/core/src/main/java/hudson/model/RunParameterValue.java +++ b/core/src/main/java/hudson/model/RunParameterValue.java @@ -28,7 +28,7 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.export.Exported; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.util.Locale; public class RunParameterValue extends ParameterValue { diff --git a/core/src/main/java/hudson/model/RunnerStack.java b/core/src/main/java/hudson/model/RunnerStack.java index 8065ce9cac9f..0e93b5316824 100644 --- a/core/src/main/java/hudson/model/RunnerStack.java +++ b/core/src/main/java/hudson/model/RunnerStack.java @@ -28,7 +28,7 @@ import java.util.Stack; import java.util.Map; import java.util.WeakHashMap; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Keeps track of {@link RunExecution}s that are currently executing on the given thread diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java index 32db580e1be4..982b77bbe5ed 100644 --- a/core/src/main/java/hudson/model/Slave.java +++ b/core/src/main/java/hudson/model/Slave.java @@ -64,8 +64,8 @@ import java.util.jar.Manifest; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import jenkins.model.Jenkins; import jenkins.security.MasterToSlaveCallable; @@ -181,7 +181,7 @@ public Slave(String name, String nodeDescription, String remoteFS, int numExecut this(name, nodeDescription, remoteFS, numExecutors, mode, labelString, launcher, retentionStrategy, new ArrayList()); } - public Slave(@Nonnull String name, String remoteFS, ComputerLauncher launcher) throws FormException, IOException { + public Slave(@NonNull String name, String remoteFS, ComputerLauncher launcher) throws FormException, IOException { this.name = name; this.remoteFS = remoteFS; this.launcher = launcher; @@ -192,7 +192,7 @@ public Slave(@Nonnull String name, String remoteFS, ComputerLauncher launcher) t * Use {@link #Slave(String, String, ComputerLauncher)} and set the rest through setters. */ @Deprecated - public Slave(@Nonnull String name, String nodeDescription, String remoteFS, int numExecutors, + public Slave(@NonNull String name, String nodeDescription, String remoteFS, int numExecutors, Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List> nodeProperties) throws FormException, IOException { this.name = name; this.description = nodeDescription; @@ -479,7 +479,7 @@ public byte[] readFully() throws IOException { * If there is no computer it will return a {@link hudson.Launcher.DummyLauncher}, otherwise it * will return a {@link hudson.Launcher.RemoteLauncher} instead. */ - @Nonnull + @NonNull public Launcher createLauncher(TaskListener listener) { SlaveComputer c = getComputer(); if (c == null) { @@ -526,7 +526,7 @@ public Launcher createLauncher(TaskListener listener) { } } - private void reportLauncherCreateError(@Nonnull String humanReadableMsg, @CheckForNull String exceptionDetails, @Nonnull TaskListener listener) { + private void reportLauncherCreateError(@NonNull String humanReadableMsg, @CheckForNull String exceptionDetails, @NonNull TaskListener listener) { String message = "Issue with creating launcher for agent " + name + ". " + humanReadableMsg; listener.error(message); if (LOGGER.isLoggable(Level.WARNING)) { @@ -609,7 +609,7 @@ public FormValidation doCheckRemoteFS(@QueryParameter String value) throws IOExc * @return the filtered list * @since 2.12 */ - @Nonnull + @NonNull @Restricted(NoExternalUse.class) // intended for use by Jelly EL only (plus hack in DelegatingComputerLauncher) public final List> computerLauncherDescriptors(@CheckForNull Slave it) { DescriptorExtensionList> all = @@ -626,7 +626,7 @@ public final List> computerLauncherDescriptors(@Che * @return the filtered list * @since 2.12 */ - @Nonnull + @NonNull @SuppressWarnings("unchecked") // used by Jelly EL only @Restricted(NoExternalUse.class) // used by Jelly EL only public final List>> retentionStrategyDescriptors(@CheckForNull Slave it) { @@ -641,7 +641,7 @@ public final List>> retentionStrategyDescriptors * @return the filtered list * @since 2.12 */ - @Nonnull + @NonNull @SuppressWarnings("unchecked") // used by Jelly EL only @Restricted(NoExternalUse.class) // used by Jelly EL only public final List nodePropertyDescriptors(@CheckForNull Slave it) { diff --git a/core/src/main/java/hudson/model/StringParameterDefinition.java b/core/src/main/java/hudson/model/StringParameterDefinition.java index c9925665588f..ff2f007b65dd 100644 --- a/core/src/main/java/hudson/model/StringParameterDefinition.java +++ b/core/src/main/java/hudson/model/StringParameterDefinition.java @@ -25,7 +25,7 @@ import hudson.Extension; import hudson.Util; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import net.sf.json.JSONObject; import org.jenkinsci.Symbol; import org.kohsuke.accmod.Restricted; @@ -48,7 +48,6 @@ public StringParameterDefinition(String name, String defaultValue, String descri this.trim = trim; } - @Nonnull public StringParameterDefinition(String name, String defaultValue, String description) { this(name, defaultValue, description, false); } diff --git a/core/src/main/java/hudson/model/TaskListener.java b/core/src/main/java/hudson/model/TaskListener.java index bbc1236f531c..96a9a43e0ded 100644 --- a/core/src/main/java/hudson/model/TaskListener.java +++ b/core/src/main/java/hudson/model/TaskListener.java @@ -36,7 +36,7 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Formatter; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.remoting.SerializableOnlyOverRemoting; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -70,7 +70,7 @@ public interface TaskListener extends SerializableOnlyOverRemoting { /** * This writer will receive the output of the build */ - @Nonnull + @NonNull PrintStream getLogger(); /** @@ -79,7 +79,7 @@ public interface TaskListener extends SerializableOnlyOverRemoting { * @return by default, UTF-8 */ @Restricted(ProtectedExternally.class) - @Nonnull + @NonNull default Charset getCharset() { return StandardCharsets.UTF_8; } @@ -122,7 +122,7 @@ default void hyperlink(String url, String text) throws IOException { * @return * A writer to receive details of the error. */ - @Nonnull + @NonNull default PrintWriter error(String msg) { return _error("ERROR: ", msg); } @@ -130,7 +130,7 @@ default PrintWriter error(String msg) { /** * {@link Formatter#format(String, Object[])} version of {@link #error(String)}. */ - @Nonnull + @NonNull default PrintWriter error(String format, Object... args) { return error(String.format(format,args)); } @@ -141,7 +141,7 @@ default PrintWriter error(String format, Object... args) { * @return * A writer to receive details of the error. */ - @Nonnull + @NonNull default PrintWriter fatalError(String msg) { return _error("FATAL: ", msg); } @@ -149,7 +149,7 @@ default PrintWriter fatalError(String msg) { /** * {@link Formatter#format(String, Object[])} version of {@link #fatalError(String)}. */ - @Nonnull + @NonNull default PrintWriter fatalError(String format, Object... args) { return fatalError(String.format(format, args)); } diff --git a/core/src/main/java/hudson/model/TimeZoneProperty.java b/core/src/main/java/hudson/model/TimeZoneProperty.java index 99ac6b1bbee6..b669eb8769ab 100644 --- a/core/src/main/java/hudson/model/TimeZoneProperty.java +++ b/core/src/main/java/hudson/model/TimeZoneProperty.java @@ -3,9 +3,9 @@ import hudson.Extension; import hudson.util.ListBoxModel; import hudson.util.ListBoxModel.Option; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import java.io.IOException; import java.util.TimeZone; import java.util.logging.Logger; @@ -52,7 +52,7 @@ public void setTimeZoneName(@CheckForNull String timeZoneName) { @Symbol("timezone") public static class DescriptorImpl extends UserPropertyDescriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return Messages.TimeZoneProperty_DisplayName(); diff --git a/core/src/main/java/hudson/model/TopLevelItemDescriptor.java b/core/src/main/java/hudson/model/TopLevelItemDescriptor.java index 500b396e49b2..b7942df57991 100644 --- a/core/src/main/java/hudson/model/TopLevelItemDescriptor.java +++ b/core/src/main/java/hudson/model/TopLevelItemDescriptor.java @@ -40,8 +40,8 @@ import org.kohsuke.stapler.jelly.DefaultScriptInvoker; import org.kohsuke.stapler.jelly.JellyClassTearOff; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.StringWriter; import java.util.logging.Level; import java.util.logging.Logger; @@ -145,7 +145,7 @@ public String getDisplayName() { * * @since 2.0 */ - @Nonnull + @NonNull public String getDescription() { Stapler stapler = Stapler.getCurrent(); if (stapler != null) { @@ -177,7 +177,7 @@ public String getDescription() { * * @since 2.0 */ - @Nonnull + @NonNull public String getCategoryId() { return ItemCategory.UncategorizedCategory.ID; } diff --git a/core/src/main/java/hudson/model/UpdateCenter.java b/core/src/main/java/hudson/model/UpdateCenter.java index d8e73814afce..ccdf7ef98e1d 100644 --- a/core/src/main/java/hudson/model/UpdateCenter.java +++ b/core/src/main/java/hudson/model/UpdateCenter.java @@ -77,7 +77,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.net.ssl.SSLHandshakeException; import javax.servlet.ServletException; import java.io.File; @@ -116,7 +116,7 @@ import java.util.jar.JarFile; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.util.Timer; import org.apache.commons.io.IOUtils; import org.kohsuke.accmod.Restricted; @@ -263,7 +263,7 @@ public UpdateCenter() { configure(new UpdateCenterConfiguration()); } - UpdateCenter(@Nonnull UpdateCenterConfiguration configuration) { + UpdateCenter(@NonNull UpdateCenterConfiguration configuration) { configure(configuration); } @@ -273,7 +273,7 @@ public UpdateCenter() { * @return Created Update center. {@link UpdateCenter} by default, but may be overridden * @since 2.4 */ - @Nonnull + @NonNull public static UpdateCenter createUpdateCenter(@CheckForNull UpdateCenterConfiguration config) { String requiredClassName = SystemProperties.getString(UpdateCenter.class.getName()+".className", null); if (requiredClassName == null) { @@ -307,7 +307,7 @@ public static UpdateCenter createUpdateCenter(@CheckForNull UpdateCenterConfigur return createDefaultUpdateCenter(config); } - @Nonnull + @NonNull private static UpdateCenter createDefaultUpdateCenter(@CheckForNull UpdateCenterConfiguration config) { return config != null ? new UpdateCenter(config) : new UpdateCenter(); } @@ -677,7 +677,7 @@ public String getDefaultBaseUrl() { * @return list of plugins */ @Restricted(NoExternalUse.class) - public @Nonnull List getPluginFromAllSites(String artifactId, + public @NonNull List getPluginFromAllSites(String artifactId, @CheckForNull VersionNumber minVersion) { ArrayList result = new ArrayList<>(); for (UpdateSite s : sites) { @@ -851,7 +851,7 @@ public synchronized Future addJob(UpdateCenterJob job) { return job.submit(); } - private @Nonnull ConnectionCheckJob addConnectionCheckJob(@Nonnull UpdateSite site) { + private @NonNull ConnectionCheckJob addConnectionCheckJob(@NonNull UpdateSite site) { // Create a connection check job if the site was not already in the sourcesUsed set i.e. the first // job (in the jobs list) relating to a site must be the connection check job. if (sourcesUsed.add(site)) { @@ -882,7 +882,7 @@ ConnectionCheckJob newConnectionCheckJob(UpdateSite site) { return new ConnectionCheckJob(site); } - private @CheckForNull ConnectionCheckJob getConnectionCheckJob(@Nonnull String siteId) { + private @CheckForNull ConnectionCheckJob getConnectionCheckJob(@NonNull String siteId) { UpdateSite site = getSite(siteId); if (site == null) { return null; @@ -890,7 +890,7 @@ ConnectionCheckJob newConnectionCheckJob(UpdateSite site) { return getConnectionCheckJob(site); } - private @CheckForNull ConnectionCheckJob getConnectionCheckJob(@Nonnull UpdateSite site) { + private @CheckForNull ConnectionCheckJob getConnectionCheckJob(@NonNull UpdateSite site) { synchronized (jobs) { for (UpdateCenterJob job : jobs) { if (job instanceof ConnectionCheckJob && job.site != null && job.site.getId().equals(site.getId())) { @@ -1642,7 +1642,7 @@ public String[] getStatuses() { * Enables a required plugin, provides feedback in the update center */ public class EnableJob extends InstallationJob { - public EnableJob(UpdateSite site, Authentication auth, @Nonnull Plugin plugin, boolean dynamicLoad) { + public EnableJob(UpdateSite site, Authentication auth, @NonNull Plugin plugin, boolean dynamicLoad) { super(plugin, site, auth, dynamicLoad); } @@ -1695,7 +1695,7 @@ public void run() { * A no-op, e.g. this plugin is already installed */ public class NoOpJob extends EnableJob { - public NoOpJob(UpdateSite site, Authentication auth, @Nonnull Plugin plugin) { + public NoOpJob(UpdateSite site, Authentication auth, @NonNull Plugin plugin) { super(site, auth, plugin, false); } @Override diff --git a/core/src/main/java/hudson/model/UpdateSite.java b/core/src/main/java/hudson/model/UpdateSite.java index 46e5033aae8c..21eb1ee1230b 100644 --- a/core/src/main/java/hudson/model/UpdateSite.java +++ b/core/src/main/java/hudson/model/UpdateSite.java @@ -61,9 +61,9 @@ import java.util.logging.Logger; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import io.jenkins.lib.versionnumber.JavaSpecificationVersion; import jenkins.model.Jenkins; @@ -202,12 +202,12 @@ public long getDataTimestamp() { * @since 2.222 * @throws IOException if there was an error downloading or saving the file. */ - public @Nonnull FormValidation updateDirectlyNow() throws IOException { + public @NonNull FormValidation updateDirectlyNow() throws IOException { return updateDirectlyNow(DownloadService.signatureCheck); } @Restricted(NoExternalUse.class) - public @Nonnull FormValidation updateDirectlyNow(boolean signatureCheck) throws IOException { + public @NonNull FormValidation updateDirectlyNow(boolean signatureCheck) throws IOException { return updateData(DownloadService.loadJSON(new URL(getUrl() + "?id=" + URLEncoder.encode(getId(), "UTF-8") + "&version=" + URLEncoder.encode(Jenkins.VERSION, "UTF-8"))), signatureCheck); } @@ -273,7 +273,7 @@ private FormValidation verifySignature(JSONObject o) throws IOException { * @deprecated use {@link #getJsonSignatureValidator(String)} instead. */ @Deprecated - @Nonnull + @NonNull protected JSONSignatureValidator getJsonSignatureValidator() { return getJsonSignatureValidator(null); } @@ -286,7 +286,7 @@ protected JSONSignatureValidator getJsonSignatureValidator() { * @return the signature validator. * @since 2.21 */ - @Nonnull + @NonNull protected JSONSignatureValidator getJsonSignatureValidator(@CheckForNull String name) { if (name == null) { name = signatureValidatorPrefix + " '" + id + "'"; @@ -757,7 +757,7 @@ public static final class WarningVersionRange { /** * Regular expression pattern for this version range that matches all included version numbers. */ - @Nonnull + @NonNull private final Pattern pattern; public WarningVersionRange(JSONObject o) { @@ -799,7 +799,7 @@ public enum Type { /** * The type classifier for this warning. */ - @Nonnull + @NonNull public /* final */ Type type; /** @@ -809,7 +809,7 @@ public enum Type { * possibly with a unique suffix (e.g. artifactId) if either applies to multiple components.

*/ @Exported - @Nonnull + @NonNull public final String id; /** @@ -820,14 +820,14 @@ public enum Type { * */ @Exported - @Nonnull + @NonNull public final String component; /** * A short, English language explanation for this warning. */ @Exported - @Nonnull + @NonNull public final String message; /** @@ -835,7 +835,7 @@ public enum Type { * only, so */ @Exported - @Nonnull + @NonNull public final String url; /** @@ -844,7 +844,7 @@ public enum Type { * If this list is empty, all versions of the component are considered to be affected by this warning. */ @Exported - @Nonnull + @NonNull public final List versionRanges; /** @@ -898,7 +898,7 @@ public int hashCode() { return id.hashCode(); } - public boolean isPluginWarning(@Nonnull String pluginName) { + public boolean isPluginWarning(@NonNull String pluginName) { return type == Type.PLUGIN && pluginName.equals(this.component); } @@ -935,7 +935,7 @@ public boolean isRelevant() { } } - public boolean isRelevantToVersion(@Nonnull VersionNumber version) { + public boolean isRelevantToVersion(@NonNull VersionNumber version) { if (this.versionRanges.isEmpty()) { // no version ranges specified, so all versions are affected return true; diff --git a/core/src/main/java/hudson/model/UsageStatistics.java b/core/src/main/java/hudson/model/UsageStatistics.java index a625c726a05a..06b2afb8fe3a 100644 --- a/core/src/main/java/hudson/model/UsageStatistics.java +++ b/core/src/main/java/hudson/model/UsageStatistics.java @@ -36,7 +36,7 @@ import org.apache.commons.io.output.ByteArrayOutputStream; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.crypto.Cipher; import javax.crypto.CipherOutputStream; import javax.crypto.KeyGenerator; @@ -194,7 +194,7 @@ public String getStatData() throws IOException { } } - @Nonnull + @NonNull @Override public Permission getRequiredGlobalConfigPagePermission() { return Jenkins.MANAGE; diff --git a/core/src/main/java/hudson/model/User.java b/core/src/main/java/hudson/model/User.java index 86f9c9e8c459..9d46dc7ee61a 100644 --- a/core/src/main/java/hudson/model/User.java +++ b/core/src/main/java/hudson/model/User.java @@ -62,9 +62,9 @@ import java.util.concurrent.ExecutionException; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; @@ -243,7 +243,7 @@ private XmlFile getConfigFile() { * @return the {@link jenkins.model.IdStrategy} for use with {@link User} instances. * @since 1.566 */ - @Nonnull + @NonNull public static IdStrategy idStrategy() { Jenkins j = Jenkins.get(); SecurityRealm realm = j.getSecurityRealm(); @@ -253,7 +253,7 @@ public static IdStrategy idStrategy() { return realm.getUserIdStrategy(); } - public int compareTo(@Nonnull User that) { + public int compareTo(@NonNull User that) { return idStrategy().compare(this.id, that.id); } @@ -262,11 +262,11 @@ public String getId() { return id; } - public @Nonnull String getUrl() { + public @NonNull String getUrl() { return "user/" + Util.rawEncode(idStrategy().keyFor(id)); } - public @Nonnull String getSearchUrl() { + public @NonNull String getSearchUrl() { return "/user/" + Util.rawEncode(idStrategy().keyFor(id)); } @@ -274,7 +274,7 @@ public String getId() { * The URL of the user page. */ @Exported(visibility = 999) - public @Nonnull String getAbsoluteUrl() { + public @NonNull String getAbsoluteUrl() { return Jenkins.get().getRootUrl() + getUrl(); } @@ -283,7 +283,7 @@ public String getId() { * This is configurable by the user. */ @Exported(visibility = 999) - public @Nonnull String getFullName() { + public @NonNull String getFullName() { return fullName; } @@ -320,7 +320,7 @@ public Map, UserProperty> getProperties() { /** * Updates the user object by adding a property. */ - public synchronized void addProperty(@Nonnull UserProperty p) throws IOException { + public synchronized void addProperty(@NonNull UserProperty p) throws IOException { UserProperty old = getProperty(p.getClass()); List ps = new ArrayList<>(properties); if (old != null) @@ -365,7 +365,7 @@ public T getProperty(Class clazz) { * @throws UsernameNotFoundException If this user is not a valid user in the backend {@link SecurityRealm}. * @since 1.419 */ - public @Nonnull Authentication impersonate() throws UsernameNotFoundException { + public @NonNull Authentication impersonate() throws UsernameNotFoundException { return this.impersonate(this.getUserDetailsForImpersonation()); } @@ -378,7 +378,7 @@ public T getProperty(Class clazz) { * @return userDetails for the user, in case he's not found but seems legitimate, we provide a userDetails with minimum access * @throws UsernameNotFoundException If this user is not a valid user in the backend {@link SecurityRealm}. */ - public @Nonnull UserDetails getUserDetailsForImpersonation() throws UsernameNotFoundException { + public @NonNull UserDetails getUserDetailsForImpersonation() throws UsernameNotFoundException { ImpersonatingUserDetailsService userDetailsService = new ImpersonatingUserDetailsService( Jenkins.get().getSecurityRealm().getSecurityComponents().userDetails ); @@ -424,7 +424,7 @@ private LegitimateButUnknownUserDetails(String username) throws IllegalArgumentE * @see #getUserDetailsForImpersonation() */ @Restricted(NoExternalUse.class) - public @Nonnull Authentication impersonate(@Nonnull UserDetails userDetails) { + public @NonNull Authentication impersonate(@NonNull UserDetails userDetails) { return new UsernamePasswordAuthenticationToken(userDetails.getUsername(), "", userDetails.getAuthorities()); } @@ -446,7 +446,7 @@ public void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws *

* This is used to avoid null {@link User} instance. */ - public static @Nonnull User getUnknown() { + public static @NonNull User getUnknown() { return getById(UNKNOWN_USERNAME, true); } @@ -482,7 +482,7 @@ public void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws * @return An existing or created user. May be {@code null} if a user does not exist and * {@code create} is false. */ - public static @Nullable User get(String idOrFullName, boolean create, @Nonnull Map context) { + public static @Nullable User get(String idOrFullName, boolean create, @NonNull Map context) { if (idOrFullName == null) { return null; } @@ -502,7 +502,7 @@ public void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws * @return An existing or created user. May be {@code null} if a user does not exist and * {@code create} is false. */ - private static @Nullable User getOrCreateById(@Nonnull String id, @Nonnull String fullName, boolean create) { + private static @Nullable User getOrCreateById(@NonNull String id, @NonNull String fullName, boolean create) { User u = AllUsers.get(id); if (u == null && (create || UserIdMapper.getInstance().isMapped(id))) { u = new User(id, fullName); @@ -535,7 +535,7 @@ public void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws * Otherwise use {@link #getOrCreateByIdOrFullName(String)} or {@link #get(String, boolean, Map)}. */ @Deprecated - public static @Nonnull User get(String idOrFullName) { + public static @NonNull User get(String idOrFullName) { return getOrCreateByIdOrFullName(idOrFullName); } @@ -554,7 +554,7 @@ public void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws * @return User instance. It will be created on-demand. * @since 2.91 */ - public static @Nonnull User getOrCreateByIdOrFullName(@Nonnull String idOrFullName) { + public static @NonNull User getOrCreateByIdOrFullName(@NonNull String idOrFullName) { return get(idOrFullName, true, Collections.emptyMap()); } @@ -603,7 +603,7 @@ public void doSubmitDescription(StaplerRequest req, StaplerResponse rsp) throws /** * Gets all the users. */ - public static @Nonnull Collection getAll() { + public static @NonNull Collection getAll() { final IdStrategy strategy = idStrategy(); ArrayList users = new ArrayList<>(AllUsers.values()); users.sort((o1, o2) -> strategy.compare(o1.getId(), o2.getId())); @@ -641,14 +641,14 @@ public static void rekey() { /** * Returns the user name. */ - public @Nonnull String getDisplayName() { + public @NonNull String getDisplayName() { return getFullName(); } /** * true if {@link AbstractBuild#hasParticipant} or {@link hudson.model.Cause.UserIdCause} */ - private boolean relatedTo(@Nonnull AbstractBuild b) { + private boolean relatedTo(@NonNull AbstractBuild b) { if (b.hasParticipant(this)) { return true; } @@ -669,7 +669,7 @@ private boolean relatedTo(@Nonnull AbstractBuild b) { */ @SuppressWarnings("unchecked") @WithBridgeMethods(List.class) - public @Nonnull RunList getBuilds() { + public @NonNull RunList getBuilds() { return RunList.fromJobs((Iterable) Jenkins.get(). allItems(Job.class)).filter((Predicate>) r -> r instanceof AbstractBuild && relatedTo((AbstractBuild) r)); } @@ -679,7 +679,7 @@ private boolean relatedTo(@Nonnull AbstractBuild b) { * * @since 1.191 */ - public @Nonnull Set> getProjects() { + public @NonNull Set> getProjects() { Set> r = new HashSet<>(); for (AbstractProject p : Jenkins.get().allItems(AbstractProject.class)) if (p.hasParticipant(this)) @@ -895,7 +895,7 @@ public void doRssLatest(StaplerRequest req, StaplerResponse rsp) throws IOExcept } @Override - @Nonnull + @NonNull public ACL getACL() { ACL base = Jenkins.get().getAuthorizationStrategy().getACL(this); // always allow a non-anonymous user full control of himself. @@ -920,7 +920,7 @@ public boolean canDelete() { * @return a possibly empty list * @since 1.498 */ - public @Nonnull List getAuthorities() { + public @NonNull List getAuthorities() { if (!Jenkins.get().hasPermission(Jenkins.ADMINISTER)) { return Collections.emptyList(); } @@ -1101,7 +1101,7 @@ public static abstract class CanonicalIdResolver extends AbstractDescribableImpl public static final String REALM = "realm"; @Override - public int compareTo(@Nonnull CanonicalIdResolver o) { + public int compareTo(@NonNull CanonicalIdResolver o) { // reverse priority order return Integer.compare(o.getPriority(), getPriority()); } @@ -1148,7 +1148,7 @@ public static List all() { * @since 2.93 */ @CheckForNull - public static String resolve(@Nonnull String idOrFullName, @Nonnull Map context) { + public static String resolve(@NonNull String idOrFullName, @NonNull Map context) { for (CanonicalIdResolver resolver : CanonicalIdResolver.all()) { String id = resolver.resolveCanonicalId(idOrFullName, context); if (id != null) { diff --git a/core/src/main/java/hudson/model/UserIdMapper.java b/core/src/main/java/hudson/model/UserIdMapper.java index d3cd8c034244..4858fdb8dfab 100644 --- a/core/src/main/java/hudson/model/UserIdMapper.java +++ b/core/src/main/java/hudson/model/UserIdMapper.java @@ -34,7 +34,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.io.File; import java.io.IOException; import java.nio.file.Files; diff --git a/core/src/main/java/hudson/model/View.java b/core/src/main/java/hudson/model/View.java index e5aac0cd67fa..fde5d094c465 100644 --- a/core/src/main/java/hudson/model/View.java +++ b/core/src/main/java/hudson/model/View.java @@ -54,7 +54,7 @@ import hudson.util.XStream2; import hudson.views.ListViewColumn; import hudson.widgets.Widget; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import jenkins.model.ModelObjectWithChildren; import jenkins.model.ModelObjectWithContextMenu; @@ -193,7 +193,7 @@ protected View(String name, ViewGroup owner) { /** * Gets all the items in this collection in a read-only view. */ - @Nonnull + @NonNull @Exported(name="jobs") public abstract Collection getItems(); @@ -244,7 +244,7 @@ public final TopLevelItem getJob(String name) { * @see #rename(String) */ @Exported(visibility=2,name="name") - @Nonnull + @NonNull public String getViewName() { return name; } @@ -1278,7 +1278,7 @@ public static DescriptorExtensionList all() { * NOTE: Historically this method is only ever called from a {@link StaplerRequest} * @return the list of instantiable {@link ViewDescriptor} instances for the current {@link StaplerRequest} */ - @Nonnull + @NonNull public static List allInstantiable() { List r = new ArrayList<>(); StaplerRequest request = Stapler.getCurrentRequest(); diff --git a/core/src/main/java/hudson/model/ViewDescriptor.java b/core/src/main/java/hudson/model/ViewDescriptor.java index 7e4a38f0f245..35481d30ff76 100644 --- a/core/src/main/java/hudson/model/ViewDescriptor.java +++ b/core/src/main/java/hudson/model/ViewDescriptor.java @@ -30,8 +30,8 @@ import java.util.Iterator; import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.DirectlyModifiableTopLevelItemGroup; import jenkins.model.Jenkins; import org.apache.commons.lang.StringUtils; @@ -138,7 +138,7 @@ public List> getJobFiltersDescriptors() { * @since 2.37 */ @SuppressWarnings("unused") // expose utility check method to subclasses - protected FormValidation checkDisplayName(@Nonnull View view, @CheckForNull String value) { + protected FormValidation checkDisplayName(@NonNull View view, @CheckForNull String value) { if (StringUtils.isBlank(value)) { // no custom name, no need to check return FormValidation.ok(); diff --git a/core/src/main/java/hudson/model/ViewGroup.java b/core/src/main/java/hudson/model/ViewGroup.java index 628667157aa4..b90037a5680d 100644 --- a/core/src/main/java/hudson/model/ViewGroup.java +++ b/core/src/main/java/hudson/model/ViewGroup.java @@ -33,7 +33,7 @@ import java.util.List; import jenkins.model.Jenkins; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Container of {@link View}s. @@ -69,7 +69,7 @@ public interface ViewGroup extends Saveable, ModelObject, AccessControlled { * * @since 2.174 */ - @Nonnull + @NonNull default Collection getAllViews() { final Collection views = new LinkedHashSet<>(getViews()); diff --git a/core/src/main/java/hudson/model/ViewGroupMixIn.java b/core/src/main/java/hudson/model/ViewGroupMixIn.java index c3c7fb8aa8ba..6f661d10c18c 100644 --- a/core/src/main/java/hudson/model/ViewGroupMixIn.java +++ b/core/src/main/java/hudson/model/ViewGroupMixIn.java @@ -30,8 +30,8 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Implements {@link ViewGroup} to be used as a "mix-in". @@ -64,7 +64,7 @@ public abstract class ViewGroupMixIn { /** * Returns all views in the group. This list must be modifiable and concurrently iterable. */ - @Nonnull + @NonNull protected abstract List views(); /** @@ -85,17 +85,17 @@ protected ViewGroupMixIn(ViewGroup owner) { this.owner = owner; } - public void addView(@Nonnull View v) throws IOException { + public void addView(@NonNull View v) throws IOException { v.owner = owner; views().add(v); owner.save(); } - public boolean canDelete(@Nonnull View view) { + public boolean canDelete(@NonNull View view) { return !view.isDefault(); // Cannot delete primary view } - public synchronized void deleteView(@Nonnull View view) throws IOException { + public synchronized void deleteView(@NonNull View view) throws IOException { if (views().size() <= 1) throw new IllegalStateException("Cannot delete last view"); views().remove(view); diff --git a/core/src/main/java/hudson/model/WorkspaceBrowser.java b/core/src/main/java/hudson/model/WorkspaceBrowser.java index cc685bb06193..d0c0dac088bd 100644 --- a/core/src/main/java/hudson/model/WorkspaceBrowser.java +++ b/core/src/main/java/hudson/model/WorkspaceBrowser.java @@ -28,7 +28,7 @@ import hudson.FilePath; import hudson.slaves.WorkspaceList; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Allows to access a workspace as an alternative to online build node. diff --git a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java index 9ac90b5170cc..185be158c032 100644 --- a/core/src/main/java/hudson/model/WorkspaceCleanupThread.java +++ b/core/src/main/java/hudson/model/WorkspaceCleanupThread.java @@ -36,7 +36,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import jenkins.model.ModifiableTopLevelItemGroup; import org.jenkinsci.Symbol; @@ -102,7 +102,7 @@ public static void invoke() { } } - private boolean shouldBeDeleted(@Nonnull TopLevelItem item, FilePath dir, @Nonnull Node n) throws IOException, InterruptedException { + private boolean shouldBeDeleted(@NonNull TopLevelItem item, FilePath dir, @NonNull Node n) throws IOException, InterruptedException { // TODO: the use of remoting is not optimal. // One remoting can execute "exists", "lastModified", and "delete" all at once. // (Could even invert master loop so that one FileCallable takes care of all known items.) diff --git a/core/src/main/java/hudson/model/labels/LabelAssignmentAction.java b/core/src/main/java/hudson/model/labels/LabelAssignmentAction.java index e51a4028bef1..ef65176e23b6 100644 --- a/core/src/main/java/hudson/model/labels/LabelAssignmentAction.java +++ b/core/src/main/java/hudson/model/labels/LabelAssignmentAction.java @@ -7,7 +7,7 @@ import hudson.model.Queue.QueueDecisionHandler; import hudson.model.Queue.Task; import hudson.model.queue.SubTask; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * {@link Action} that can be submitted to {@link Queue} that controls where @@ -36,5 +36,5 @@ public interface LabelAssignmentAction extends Action { * null to let other {@link LabelAssignmentAction}s take control, eventually to {@link SubTask#getAssignedLabel()}. * If non-null value is returned, that label will be authoritative. */ - Label getAssignedLabel(@Nonnull SubTask task); + Label getAssignedLabel(@NonNull SubTask task); } diff --git a/core/src/main/java/hudson/model/labels/LabelAtom.java b/core/src/main/java/hudson/model/labels/LabelAtom.java index c7c4d525d09e..16ec68c4350e 100644 --- a/core/src/main/java/hudson/model/labels/LabelAtom.java +++ b/core/src/main/java/hudson/model/labels/LabelAtom.java @@ -56,8 +56,8 @@ import java.util.Vector; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.Nullable; /** * Atomic single token label, like "foo" or "bar". diff --git a/core/src/main/java/hudson/model/listeners/RunListener.java b/core/src/main/java/hudson/model/listeners/RunListener.java index e0bbb2a3c72e..fce83e8e844f 100644 --- a/core/src/main/java/hudson/model/listeners/RunListener.java +++ b/core/src/main/java/hudson/model/listeners/RunListener.java @@ -48,7 +48,7 @@ import java.lang.reflect.Type; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Receives notifications about builds. @@ -91,7 +91,7 @@ protected RunListener() { * Any exception/error thrown from this method will be swallowed to prevent broken listeners * from breaking all the builds. */ - public void onCompleted(R r, @Nonnull TaskListener listener) {} + public void onCompleted(R r, @NonNull TaskListener listener) {} /** * Called after a build is moved to the {@code Run.State.COMPLETED} state. @@ -202,7 +202,7 @@ public void unregister() { /** * Fires the {@link #onCompleted(Run, TaskListener)} event. */ - public static void fireCompleted(Run r, @Nonnull TaskListener listener) { + public static void fireCompleted(Run r, @NonNull TaskListener listener) { for (RunListener l : all()) { if(l.targetType.isInstance(r)) try { diff --git a/core/src/main/java/hudson/model/listeners/SCMListener.java b/core/src/main/java/hudson/model/listeners/SCMListener.java index 7bc27b6be140..c3412df090f0 100644 --- a/core/src/main/java/hudson/model/listeners/SCMListener.java +++ b/core/src/main/java/hudson/model/listeners/SCMListener.java @@ -41,7 +41,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.model.Jenkins; /** diff --git a/core/src/main/java/hudson/model/queue/CauseOfBlockage.java b/core/src/main/java/hudson/model/queue/CauseOfBlockage.java index aea7889d3b76..c75d9ed72cc7 100644 --- a/core/src/main/java/hudson/model/queue/CauseOfBlockage.java +++ b/core/src/main/java/hudson/model/queue/CauseOfBlockage.java @@ -8,7 +8,7 @@ import hudson.model.Label; import hudson.model.TaskListener; import hudson.slaves.Cloud; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jvnet.localizer.Localizable; /** @@ -44,7 +44,7 @@ public void print(TaskListener listener) { /** * Obtains a simple implementation backed by {@link Localizable}. */ - public static CauseOfBlockage fromMessage(@Nonnull final Localizable l) { + public static CauseOfBlockage fromMessage(@NonNull final Localizable l) { l.getKey(); // null check return new CauseOfBlockage() { @Override diff --git a/core/src/main/java/hudson/model/queue/Executables.java b/core/src/main/java/hudson/model/queue/Executables.java index 426c12df96e5..43530ed3a8ad 100644 --- a/core/src/main/java/hudson/model/queue/Executables.java +++ b/core/src/main/java/hudson/model/queue/Executables.java @@ -27,8 +27,8 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Convenience methods around {@link Executable}. @@ -42,7 +42,7 @@ public class Executables { * @param e Executable * @return Discovered subtask */ - public static @Nonnull SubTask getParentOf(@Nonnull Executable e) + public static @NonNull SubTask getParentOf(@NonNull Executable e) throws Error, RuntimeException { try { return e.getParent(); diff --git a/core/src/main/java/hudson/model/queue/FutureImpl.java b/core/src/main/java/hudson/model/queue/FutureImpl.java index d7151f644cc3..b0e56a2199f5 100644 --- a/core/src/main/java/hudson/model/queue/FutureImpl.java +++ b/core/src/main/java/hudson/model/queue/FutureImpl.java @@ -34,7 +34,7 @@ import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Created when {@link hudson.model.Queue.Item} is created so that the caller can track the progress of the task. @@ -92,7 +92,7 @@ public synchronized void setAsCancelled() { } } - synchronized void addExecutor(@Nonnull Executor executor) { + synchronized void addExecutor(@NonNull Executor executor) { this.executors.add(executor); } } diff --git a/core/src/main/java/hudson/model/queue/QueueTaskDispatcher.java b/core/src/main/java/hudson/model/queue/QueueTaskDispatcher.java index cd5c5d5b0cc9..dc1fd3d2eabf 100644 --- a/core/src/main/java/hudson/model/queue/QueueTaskDispatcher.java +++ b/core/src/main/java/hudson/model/queue/QueueTaskDispatcher.java @@ -33,7 +33,7 @@ import hudson.model.Queue.BuildableItem; import hudson.model.Queue.Task; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Vetos the execution of a task on a node diff --git a/core/src/main/java/hudson/model/queue/QueueTaskFilter.java b/core/src/main/java/hudson/model/queue/QueueTaskFilter.java index 9bf4887247da..e32073f1aa91 100644 --- a/core/src/main/java/hudson/model/queue/QueueTaskFilter.java +++ b/core/src/main/java/hudson/model/queue/QueueTaskFilter.java @@ -33,7 +33,7 @@ import java.io.IOException; import java.util.Collection; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Base class for defining filter {@link hudson.model.Queue.Task}. diff --git a/core/src/main/java/hudson/model/queue/ScheduleResult.java b/core/src/main/java/hudson/model/queue/ScheduleResult.java index 95ebf0394ac4..82b6e6df2a89 100644 --- a/core/src/main/java/hudson/model/queue/ScheduleResult.java +++ b/core/src/main/java/hudson/model/queue/ScheduleResult.java @@ -5,7 +5,7 @@ import hudson.model.Queue.Item; import hudson.model.Queue.Task; import hudson.model.Queue.WaitingItem; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Result of {@link Queue#schedule2} diff --git a/core/src/main/java/hudson/model/queue/SubTask.java b/core/src/main/java/hudson/model/queue/SubTask.java index 485bebc10916..f16931759f75 100644 --- a/core/src/main/java/hudson/model/queue/SubTask.java +++ b/core/src/main/java/hudson/model/queue/SubTask.java @@ -31,9 +31,9 @@ import hudson.model.Queue.Task; import hudson.model.ResourceActivity; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * A component of {@link Task} that represents a computation carried out by a single {@link Executor}. @@ -90,7 +90,7 @@ default long getEstimatedDuration() { * Gets the {@link Task} that this subtask belongs to. * @return by default, {@code this} */ - default @Nonnull Task getOwnerTask() { + default @NonNull Task getOwnerTask() { return (Task) this; } diff --git a/core/src/main/java/hudson/model/queue/Tasks.java b/core/src/main/java/hudson/model/queue/Tasks.java index baf2f9714f3b..c591fe494075 100644 --- a/core/src/main/java/hudson/model/queue/Tasks.java +++ b/core/src/main/java/hudson/model/queue/Tasks.java @@ -26,11 +26,11 @@ import hudson.model.Queue; import hudson.model.Queue.Item; import hudson.model.Queue.Task; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.acegisecurity.Authentication; import java.util.Collection; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.security.QueueItemAuthenticator; import jenkins.security.QueueItemAuthenticatorProvider; @@ -56,7 +56,7 @@ public static Object getSameNodeConstraintOf(SubTask t) { /** deprecated call {@link SubTask#getOwnerTask} directly */ @Deprecated - public static @Nonnull Task getOwnerTaskOf(@Nonnull SubTask t) { + public static @NonNull Task getOwnerTaskOf(@NonNull SubTask t) { return t.getOwnerTask(); } @@ -68,7 +68,7 @@ public static Object getSameNodeConstraintOf(SubTask t) { * @since 2.55 */ @CheckForNull - public static hudson.model.Item getItemOf(@Nonnull SubTask t) { + public static hudson.model.Item getItemOf(@NonNull SubTask t) { Queue.Task p = t.getOwnerTask(); while (!(p instanceof hudson.model.Item)) { Queue.Task o = p.getOwnerTask(); @@ -82,14 +82,14 @@ public static hudson.model.Item getItemOf(@Nonnull SubTask t) { /** @deprecated call {@link Task#getDefaultAuthentication()} directly */ @Deprecated - @Nonnull + @NonNull public static Authentication getDefaultAuthenticationOf(Task t) { return t.getDefaultAuthentication(); } /** @deprecated call {@link Task#getDefaultAuthentication(Item)} directly */ @Deprecated - @Nonnull + @NonNull public static Authentication getDefaultAuthenticationOf(Task t, Item item) { return t.getDefaultAuthentication(item); } @@ -102,7 +102,7 @@ public static Authentication getDefaultAuthenticationOf(Task t, Item item) { * @return an authentication as specified by some {@link QueueItemAuthenticator#authenticate(hudson.model.Queue.Task)}; else {@link Task#getDefaultAuthentication()} * @since 1.560 */ - public static @Nonnull Authentication getAuthenticationOf(@Nonnull Task t) { + public static @NonNull Authentication getAuthenticationOf(@NonNull Task t) { for (QueueItemAuthenticator qia : QueueItemAuthenticatorProvider.authenticators()) { Authentication a = qia.authenticate(t); if (a != null) { diff --git a/core/src/main/java/hudson/model/queue/WorkUnit.java b/core/src/main/java/hudson/model/queue/WorkUnit.java index 7665c42a0e1d..541485b8adbf 100644 --- a/core/src/main/java/hudson/model/queue/WorkUnit.java +++ b/core/src/main/java/hudson/model/queue/WorkUnit.java @@ -27,7 +27,7 @@ import hudson.model.Queue; import hudson.model.Queue.Executable; import hudson.model.Queue.Task; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.model.Run; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; diff --git a/core/src/main/java/hudson/node_monitors/AbstractAsyncNodeMonitorDescriptor.java b/core/src/main/java/hudson/node_monitors/AbstractAsyncNodeMonitorDescriptor.java index 5b567ab8ad9c..b7f2ab15ff0c 100644 --- a/core/src/main/java/hudson/node_monitors/AbstractAsyncNodeMonitorDescriptor.java +++ b/core/src/main/java/hudson/node_monitors/AbstractAsyncNodeMonitorDescriptor.java @@ -7,8 +7,8 @@ import hudson.slaves.SlaveComputer; import jenkins.model.Jenkins; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -81,7 +81,7 @@ protected Map monitor() throws InterruptedException { /** * Perform monitoring with detailed reporting. */ - protected final @Nonnull Result monitorDetailed() throws InterruptedException { + protected final @NonNull Result monitorDetailed() throws InterruptedException { Map> futures = new HashMap<>(); Set skipped = new HashSet<>(); @@ -157,15 +157,15 @@ private void error(Computer c, Throwable x) { protected static final class Result { private static final long serialVersionUID = -7671448355804481216L; - private final @Nonnull Map data; - private final @Nonnull ArrayList skipped; + private final @NonNull Map data; + private final @NonNull ArrayList skipped; - private Result(@Nonnull Map data, @Nonnull Collection skipped) { + private Result(@NonNull Map data, @NonNull Collection skipped) { this.data = new HashMap<>(data); this.skipped = new ArrayList<>(skipped); } - protected @Nonnull Map getMonitoringData() { + protected @NonNull Map getMonitoringData() { return data; } @@ -173,7 +173,7 @@ private Result(@Nonnull Map data, @Nonnull Collection ski * Computers that ware skipped during monitoring as they either do not have a a channel (offline) or the monitor * have not produced the Callable. Computers that caused monitor to throw exception are not returned here. */ - protected @Nonnull List getSkipped() { + protected @NonNull List getSkipped() { return skipped; } } diff --git a/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java b/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java index 267a24390a5e..bba32306f0c6 100644 --- a/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java +++ b/core/src/main/java/hudson/node_monitors/AbstractNodeMonitorDescriptor.java @@ -34,7 +34,7 @@ import jenkins.util.SystemProperties; import jenkins.util.Timer; -import javax.annotation.concurrent.GuardedBy; +import net.jcip.annotations.GuardedBy; import java.io.IOException; import java.util.Collections; import java.util.Date; diff --git a/core/src/main/java/hudson/node_monitors/MonitorOfflineCause.java b/core/src/main/java/hudson/node_monitors/MonitorOfflineCause.java index 4b7c5b60085f..77c3285cd70e 100644 --- a/core/src/main/java/hudson/node_monitors/MonitorOfflineCause.java +++ b/core/src/main/java/hudson/node_monitors/MonitorOfflineCause.java @@ -23,7 +23,7 @@ */ package hudson.node_monitors; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.slaves.OfflineCause; @@ -38,5 +38,5 @@ public abstract class MonitorOfflineCause extends OfflineCause { /** * Identify monitor implementation that put computer offline. */ - public abstract @Nonnull Class getTrigger(); + public abstract @NonNull Class getTrigger(); } diff --git a/core/src/main/java/hudson/node_monitors/NodeMonitor.java b/core/src/main/java/hudson/node_monitors/NodeMonitor.java index b0e5f2fe4015..bc04c75569d2 100644 --- a/core/src/main/java/hudson/node_monitors/NodeMonitor.java +++ b/core/src/main/java/hudson/node_monitors/NodeMonitor.java @@ -36,7 +36,7 @@ import hudson.util.DescriptorList; import java.util.List; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; diff --git a/core/src/main/java/hudson/os/WindowsUtil.java b/core/src/main/java/hudson/os/WindowsUtil.java index 77f72b6c4a43..116820fac26d 100644 --- a/core/src/main/java/hudson/os/WindowsUtil.java +++ b/core/src/main/java/hudson/os/WindowsUtil.java @@ -27,7 +27,7 @@ import hudson.Functions; import org.apache.commons.io.IOUtils; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -50,7 +50,7 @@ public class WindowsUtil { * @param argument argument to be quoted or escaped for windows shells. * @return properly quoted and escaped windows arguments. */ - public static @Nonnull String quoteArgument(@Nonnull String argument) { + public static @NonNull String quoteArgument(@NonNull String argument) { if (!NEEDS_QUOTING.matcher(argument).find()) return argument; StringBuilder sb = new StringBuilder(); sb.append('"'); @@ -89,7 +89,7 @@ public class WindowsUtil { * @param argument argument to be quoted or escaped for {@code cmd.exe}. * @return properly quoted and escaped arguments to {@code cmd.exe}. */ - public static @Nonnull String quoteArgumentForCmd(@Nonnull String argument) { + public static @NonNull String quoteArgumentForCmd(@NonNull String argument) { return CMD_METACHARS.matcher(quoteArgument(argument)).replaceAll("^$0"); } @@ -98,7 +98,7 @@ public class WindowsUtil { * @param argv arguments to be quoted or escaped for {@code cmd.exe /C ...}. * @return properly quoted and escaped arguments to {@code cmd.exe /C ...}. */ - public static @Nonnull Process execCmd(String... argv) throws IOException { + public static @NonNull Process execCmd(String... argv) throws IOException { String command = Arrays.stream(argv).map(WindowsUtil::quoteArgumentForCmd).collect(Collectors.joining(" ")); return Runtime.getRuntime().exec(new String[]{"cmd.exe", "/C", command}); } @@ -113,7 +113,7 @@ public class WindowsUtil { * @throws InterruptedException if the call to mklink is interrupted before completing * @throws UnsupportedOperationException if this method is called on a non-Windows platform */ - public static @Nonnull File createJunction(@Nonnull File junction, @Nonnull File target) throws IOException, InterruptedException { + public static @NonNull File createJunction(@NonNull File junction, @NonNull File target) throws IOException, InterruptedException { if (!Functions.isWindows()) { throw new UnsupportedOperationException("Can only be called on windows platform"); } diff --git a/core/src/main/java/hudson/scheduler/CronTab.java b/core/src/main/java/hudson/scheduler/CronTab.java index 77118499ad75..8b2d507b9fff 100644 --- a/core/src/main/java/hudson/scheduler/CronTab.java +++ b/core/src/main/java/hudson/scheduler/CronTab.java @@ -34,7 +34,7 @@ import java.util.regex.Pattern; import static java.util.Calendar.*; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Table for driving scheduled tasks. diff --git a/core/src/main/java/hudson/scheduler/CronTabList.java b/core/src/main/java/hudson/scheduler/CronTabList.java index edeb6e0a3700..97dd53dd7676 100644 --- a/core/src/main/java/hudson/scheduler/CronTabList.java +++ b/core/src/main/java/hudson/scheduler/CronTabList.java @@ -28,8 +28,8 @@ import java.util.TimeZone; import java.util.Collection; import java.util.Vector; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -92,11 +92,11 @@ public String checkSanity() { return null; } - public static CronTabList create(@Nonnull String format) throws ANTLRException { + public static CronTabList create(@NonNull String format) throws ANTLRException { return create(format,null); } - public static CronTabList create(@Nonnull String format, Hash hash) throws ANTLRException { + public static CronTabList create(@NonNull String format, Hash hash) throws ANTLRException { Vector r = new Vector<>(); int lineNumber = 0; String timezone = null; diff --git a/core/src/main/java/hudson/scm/PollingResult.java b/core/src/main/java/hudson/scm/PollingResult.java index 39b3a0caba81..718b98cfc2e7 100644 --- a/core/src/main/java/hudson/scm/PollingResult.java +++ b/core/src/main/java/hudson/scm/PollingResult.java @@ -5,8 +5,8 @@ import hudson.Launcher; import hudson.FilePath; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.Serializable; /** @@ -41,7 +41,7 @@ public final class PollingResult implements Serializable { * the immediate rebuild, and (2) allow SCM to ignore some changes in the repository to implement * exclusion feature. */ - public final @Nonnull Change change; + public final @NonNull Change change; /** * Degree of changes between the previous state and this state. @@ -79,14 +79,14 @@ public enum Change { INCOMPARABLE } - public PollingResult(@CheckForNull SCMRevisionState baseline, @CheckForNull SCMRevisionState remote, @Nonnull Change change) { + public PollingResult(@CheckForNull SCMRevisionState baseline, @CheckForNull SCMRevisionState remote, @NonNull Change change) { if (change==null) throw new IllegalArgumentException(); this.baseline = baseline; this.remote = remote; this.change = change; } - public PollingResult(@Nonnull Change change) { + public PollingResult(@NonNull Change change) { this(null,null,change); } diff --git a/core/src/main/java/hudson/scm/SCM.java b/core/src/main/java/hudson/scm/SCM.java index 13e66c3873b1..63180e9691b0 100644 --- a/core/src/main/java/hudson/scm/SCM.java +++ b/core/src/main/java/hudson/scm/SCM.java @@ -56,9 +56,9 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import jenkins.model.Jenkins; import jenkins.util.SystemProperties; import org.kohsuke.stapler.export.Exported; @@ -232,7 +232,7 @@ public boolean requiresWorkspaceForPolling() { * * @since 1.568 */ - public boolean processWorkspaceBeforeDeletion(@Nonnull Job project, @Nonnull FilePath workspace, @Nonnull Node node) throws IOException, InterruptedException { + public boolean processWorkspaceBeforeDeletion(@NonNull Job project, @NonNull FilePath workspace, @NonNull Node node) throws IOException, InterruptedException { if (project instanceof AbstractProject) { return processWorkspaceBeforeDeletion((AbstractProject) project, workspace, node); } else { @@ -329,7 +329,7 @@ public boolean pollChanges(AbstractProject project, Launcher launcher, File * this exception should be simply propagated all the way up. * @since 1.568 */ - public @CheckForNull SCMRevisionState calcRevisionsFromBuild(@Nonnull Run build, @Nullable FilePath workspace, @Nullable Launcher launcher, @Nonnull TaskListener listener) throws IOException, InterruptedException { + public @CheckForNull SCMRevisionState calcRevisionsFromBuild(@NonNull Run build, @Nullable FilePath workspace, @Nullable Launcher launcher, @NonNull TaskListener listener) throws IOException, InterruptedException { if (build instanceof AbstractBuild && Util.isOverridden(SCM.class, getClass(), "calcRevisionsFromBuild", AbstractBuild.class, Launcher.class, TaskListener.class)) { return calcRevisionsFromBuild((AbstractBuild) build, launcher, listener); } else { @@ -388,7 +388,7 @@ public SCMRevisionState _calcRevisionsFromBuild(AbstractBuild build, Launc * this exception should be simply propagated all the way up. * @since 1.568 */ - public PollingResult compareRemoteRevisionWith(@Nonnull Job project, @Nullable Launcher launcher, @Nullable FilePath workspace, @Nonnull TaskListener listener, @Nonnull SCMRevisionState baseline) throws IOException, InterruptedException { + public PollingResult compareRemoteRevisionWith(@NonNull Job project, @Nullable Launcher launcher, @Nullable FilePath workspace, @NonNull TaskListener listener, @NonNull SCMRevisionState baseline) throws IOException, InterruptedException { if (project instanceof AbstractProject && Util.isOverridden(SCM.class, getClass(), "compareRemoteRevisionWith", AbstractProject.class, Launcher.class, FilePath.class, TaskListener.class, SCMRevisionState.class)) { return compareRemoteRevisionWith((AbstractProject) project, launcher, workspace, listener, baseline); } else { @@ -446,7 +446,7 @@ private boolean is1_346OrLater() { * @return by default, just {@link #getType} * @since 1.568 */ - public @Nonnull String getKey() { + public @NonNull String getKey() { return getType(); } @@ -478,7 +478,7 @@ private boolean is1_346OrLater() { * @throws AbortException in case of a routine failure * @since 1.568 */ - public void checkout(@Nonnull Run build, @Nonnull Launcher launcher, @Nonnull FilePath workspace, @Nonnull TaskListener listener, @CheckForNull File changelogFile, @CheckForNull SCMRevisionState baseline) throws IOException, InterruptedException { + public void checkout(@NonNull Run build, @NonNull Launcher launcher, @NonNull FilePath workspace, @NonNull TaskListener listener, @CheckForNull File changelogFile, @CheckForNull SCMRevisionState baseline) throws IOException, InterruptedException { if (build instanceof AbstractBuild && listener instanceof BuildListener && Util.isOverridden(SCM.class, getClass(), "checkout", AbstractBuild.class, Launcher.class, FilePath.class, BuildListener.class, File.class)) { if (changelogFile == null) { changelogFile = File.createTempFile("changelog", ".xml"); @@ -500,7 +500,7 @@ public void checkout(@Nonnull Run build, @Nonnull Launcher launcher, @Nonnu } @Deprecated - public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, @Nonnull File changelogFile) throws IOException, InterruptedException { + public boolean checkout(AbstractBuild build, Launcher launcher, FilePath workspace, BuildListener listener, @NonNull File changelogFile) throws IOException, InterruptedException { AbstractBuild prev = build.getPreviousBuild(); checkout((Run) build, launcher, workspace, listener, changelogFile, prev != null ? prev.getAction(SCMRevisionState.class) : null); return true; @@ -510,7 +510,7 @@ public boolean checkout(AbstractBuild build, Launcher launcher, FilePath wo * Get a chance to do operations after the workspace i checked out and the changelog is written. * @since 1.568 */ - public void postCheckout(@Nonnull Run build, @Nonnull Launcher launcher, @Nonnull FilePath workspace, @Nonnull TaskListener listener) throws IOException, InterruptedException { + public void postCheckout(@NonNull Run build, @NonNull Launcher launcher, @NonNull FilePath workspace, @NonNull TaskListener listener) throws IOException, InterruptedException { if (build instanceof AbstractBuild && listener instanceof BuildListener) { postCheckout((AbstractBuild) build, launcher, workspace, (BuildListener) listener); } @@ -539,7 +539,7 @@ public void postCheckout(AbstractBuild build, Launcher launcher, FilePath w * * @since 2.60 */ - public void buildEnvironment(@Nonnull Run build, @Nonnull Map env) { + public void buildEnvironment(@NonNull Run build, @NonNull Map env) { if (build instanceof AbstractBuild) { buildEnvVars((AbstractBuild)build, env); } @@ -705,7 +705,7 @@ protected final boolean createEmptyChangeLog(File changelogFile, BuildListener l /** * @since 1.568 */ - protected final void createEmptyChangeLog(@Nonnull File changelogFile, @Nonnull TaskListener listener, @Nonnull String rootTag) throws IOException { + protected final void createEmptyChangeLog(@NonNull File changelogFile, @NonNull TaskListener listener, @NonNull String rootTag) throws IOException { try (FileWriter w = new FileWriter(changelogFile)) { w.write("<"+rootTag +"/>"); } diff --git a/core/src/main/java/hudson/search/CollectionSearchIndex.java b/core/src/main/java/hudson/search/CollectionSearchIndex.java index 7bbbc609ee24..3f60912381d2 100644 --- a/core/src/main/java/hudson/search/CollectionSearchIndex.java +++ b/core/src/main/java/hudson/search/CollectionSearchIndex.java @@ -27,7 +27,7 @@ import java.util.Collections; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * {@link SearchIndex} built on a {@link Map}. @@ -46,7 +46,7 @@ public abstract class CollectionSearchIndex i */ protected abstract Collection all(); - @Nonnull + @NonNull protected Iterable allAsIterable() { Collection all = all(); return all == null ? Collections.emptySet() : all; diff --git a/core/src/main/java/hudson/search/Search.java b/core/src/main/java/hudson/search/Search.java index e21014a8d4f6..8c2ac966ed9e 100644 --- a/core/src/main/java/hudson/search/Search.java +++ b/core/src/main/java/hudson/search/Search.java @@ -38,7 +38,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.ServletException; import jenkins.util.MemoryReductionUtil; diff --git a/core/src/main/java/hudson/security/ACL.java b/core/src/main/java/hudson/security/ACL.java index fa9b1df76ef8..4ae5a3b3e0fc 100644 --- a/core/src/main/java/hudson/security/ACL.java +++ b/core/src/main/java/hudson/security/ACL.java @@ -32,8 +32,8 @@ import java.util.LinkedHashSet; import java.util.Set; import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.Item; import hudson.remoting.Callable; @@ -69,7 +69,7 @@ public abstract class ACL { * @throws AccessDeniedException * if the user doesn't have the permission. */ - public final void checkPermission(@Nonnull Permission p) { + public final void checkPermission(@NonNull Permission p) { Authentication a = Jenkins.getAuthentication(); if (a == SYSTEM) { return; @@ -94,7 +94,7 @@ public final void checkPermission(@Nonnull Permission p) { * * @since 2.222 */ - public final void checkAnyPermission(@Nonnull Permission... permissions) { + public final void checkAnyPermission(@NonNull Permission... permissions) { if (permissions.length == 0) { throw new IllegalArgumentException("At least one permission must be provided"); } @@ -131,7 +131,7 @@ public final void checkAnyPermission(@Nonnull Permission... permissions) { * @return false * if the user doesn't have the permission. */ - public final boolean hasPermission(@Nonnull Permission p) { + public final boolean hasPermission(@NonNull Permission p) { Authentication a = Jenkins.getAuthentication(); if (a == SYSTEM) { return true; @@ -148,7 +148,7 @@ public final boolean hasPermission(@Nonnull Permission p) { * @throws IllegalArgumentException * if no permissions are provided */ - public final boolean hasAnyPermission(@Nonnull Permission... permissions) { + public final boolean hasAnyPermission(@NonNull Permission... permissions) { if (permissions.length == 0) { throw new IllegalArgumentException("At least one permission must be provided"); } @@ -173,7 +173,7 @@ public final boolean hasAnyPermission(@Nonnull Permission... permissions) { * Note that {@link #SYSTEM} can be passed in as the authentication parameter, * in which case you should probably just assume it has every permission. */ - public abstract boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission); + public abstract boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission); /** * Creates a simple {@link ACL} implementation based on a “single-abstract-method” easily implemented via lambda syntax. @@ -201,8 +201,8 @@ public boolean hasPermission(Authentication a, Permission permission) { * if the user doesn't have the permission. * @since 1.607 */ - public final void checkCreatePermission(@Nonnull ItemGroup c, - @Nonnull TopLevelItemDescriptor d) { + public final void checkCreatePermission(@NonNull ItemGroup c, + @NonNull TopLevelItemDescriptor d) { Authentication a = Jenkins.getAuthentication(); if (a == SYSTEM) { return; @@ -224,8 +224,8 @@ public final void checkCreatePermission(@Nonnull ItemGroup c, * if the user doesn't have the permission. * @since 1.607 */ - public boolean hasCreatePermission(@Nonnull Authentication a, @Nonnull ItemGroup c, - @Nonnull TopLevelItemDescriptor d) { + public boolean hasCreatePermission(@NonNull Authentication a, @NonNull ItemGroup c, + @NonNull TopLevelItemDescriptor d) { return true; } @@ -239,8 +239,8 @@ public boolean hasCreatePermission(@Nonnull Authentication a, @Nonnull ItemGroup * @throws AccessDeniedException if the user doesn't have the permission. * @since 1.607 */ - public final void checkCreatePermission(@Nonnull ViewGroup c, - @Nonnull ViewDescriptor d) { + public final void checkCreatePermission(@NonNull ViewGroup c, + @NonNull ViewDescriptor d) { Authentication a = Jenkins.getAuthentication(); if (a == SYSTEM) { return; @@ -263,8 +263,8 @@ public final void checkCreatePermission(@Nonnull ViewGroup c, * if the user doesn't have the permission. * @since 2.37 */ - public boolean hasCreatePermission(@Nonnull Authentication a, @Nonnull ViewGroup c, - @Nonnull ViewDescriptor d) { + public boolean hasCreatePermission(@NonNull Authentication a, @NonNull ViewGroup c, + @NonNull ViewDescriptor d) { return true; } @@ -332,7 +332,7 @@ public String toString() { * @deprecated use try with resources and {@link #as(Authentication)} */ @Deprecated - public static @Nonnull SecurityContext impersonate(@Nonnull Authentication auth) { + public static @NonNull SecurityContext impersonate(@NonNull Authentication auth) { SecurityContext old = SecurityContextHolder.getContext(); SecurityContextHolder.setContext(new NonSerializableSecurityContext(auth)); return old; @@ -346,7 +346,7 @@ public String toString() { * @deprecated use try with resources and {@link #as(Authentication)} */ @Deprecated - public static void impersonate(@Nonnull Authentication auth, @Nonnull Runnable body) { + public static void impersonate(@NonNull Authentication auth, @NonNull Runnable body) { SecurityContext old = impersonate(auth); try { body.run(); @@ -387,8 +387,8 @@ public static V impersonate(Authentication auth, Callabl * @return the previous authentication context * @since 2.14 */ - @Nonnull - public static ACLContext as(@Nonnull Authentication auth) { + @NonNull + public static ACLContext as(@NonNull Authentication auth) { final ACLContext context = new ACLContext(SecurityContextHolder.getContext()); SecurityContextHolder.setContext(new NonSerializableSecurityContext(auth)); return context; @@ -410,7 +410,7 @@ public static ACLContext as(@Nonnull Authentication auth) { * @return the previous authentication context * @since 2.14 */ - @Nonnull + @NonNull public static ACLContext as(@CheckForNull User user) { return as(user == null ? Jenkins.ANONYMOUS : user.impersonate()); } @@ -420,7 +420,7 @@ public static ACLContext as(@CheckForNull User user) { * @see Jenkins#ANONYMOUS * @see AnonymousAuthenticationToken */ - public static boolean isAnonymous(@Nonnull Authentication authentication) { + public static boolean isAnonymous(@NonNull Authentication authentication) { //TODO use AuthenticationTrustResolver instead to be consistent through the application return authentication instanceof AnonymousAuthenticationToken; } diff --git a/core/src/main/java/hudson/security/ACLContext.java b/core/src/main/java/hudson/security/ACLContext.java index ffcdf4b9514b..2f1b4e207d6b 100644 --- a/core/src/main/java/hudson/security/ACLContext.java +++ b/core/src/main/java/hudson/security/ACLContext.java @@ -23,7 +23,7 @@ */ package hudson.security; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.acegisecurity.Authentication; import org.acegisecurity.context.SecurityContext; import org.acegisecurity.context.SecurityContextHolder; @@ -38,14 +38,14 @@ public class ACLContext implements AutoCloseable { /** * The previous context. */ - @Nonnull + @NonNull private final SecurityContext previousContext; /** * Private constructor to ensure only instance creation is from {@link ACL#as(Authentication)}. * @param previousContext the previous context */ - ACLContext(@Nonnull SecurityContext previousContext) { + ACLContext(@NonNull SecurityContext previousContext) { this.previousContext = previousContext; } @@ -53,7 +53,7 @@ public class ACLContext implements AutoCloseable { * Accessor for the previous context. * @return the previous context. */ - @Nonnull + @NonNull public SecurityContext getPreviousContext() { return previousContext; } diff --git a/core/src/main/java/hudson/security/AccessControlled.java b/core/src/main/java/hudson/security/AccessControlled.java index 9ea9272300ed..5e12debb3c3a 100644 --- a/core/src/main/java/hudson/security/AccessControlled.java +++ b/core/src/main/java/hudson/security/AccessControlled.java @@ -23,7 +23,7 @@ */ package hudson.security; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.acegisecurity.AccessDeniedException; import org.acegisecurity.Authentication; @@ -38,12 +38,12 @@ public interface AccessControlled { * * @return never null. */ - @Nonnull ACL getACL(); + @NonNull ACL getACL(); /** * Convenient short-cut for {@code getACL().checkPermission(permission)} */ - default void checkPermission(@Nonnull Permission permission) throws AccessDeniedException { + default void checkPermission(@NonNull Permission permission) throws AccessDeniedException { getACL().checkPermission(permission); } @@ -53,14 +53,14 @@ default void checkPermission(@Nonnull Permission permission) throws AccessDenied * * @since 2.222 */ - default void checkAnyPermission(@Nonnull Permission... permission) throws AccessDeniedException { + default void checkAnyPermission(@NonNull Permission... permission) throws AccessDeniedException { getACL().checkAnyPermission(permission); } /** * Convenient short-cut for {@code getACL().hasPermission(permission)} */ - default boolean hasPermission(@Nonnull Permission permission) { + default boolean hasPermission(@NonNull Permission permission) { return getACL().hasPermission(permission); } @@ -70,7 +70,7 @@ default boolean hasPermission(@Nonnull Permission permission) { * * @since 2.222 */ - default boolean hasAnyPermission(@Nonnull Permission... permission) { + default boolean hasAnyPermission(@NonNull Permission... permission) { return getACL().hasAnyPermission(permission); } @@ -78,7 +78,7 @@ default boolean hasAnyPermission(@Nonnull Permission... permission) { * Convenient short-cut for {@code getACL().hasPermission(a, permission)} * @since 2.92 */ - default boolean hasPermission(@Nonnull Authentication a, @Nonnull Permission permission) { + default boolean hasPermission(@NonNull Authentication a, @NonNull Permission permission) { if (a == ACL.SYSTEM) { return true; } diff --git a/core/src/main/java/hudson/security/AuthorizationStrategy.java b/core/src/main/java/hudson/security/AuthorizationStrategy.java index e95b0c426fe5..3d63272d0f07 100644 --- a/core/src/main/java/hudson/security/AuthorizationStrategy.java +++ b/core/src/main/java/hudson/security/AuthorizationStrategy.java @@ -35,7 +35,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.Serializable; import java.util.Collection; import java.util.Collections; @@ -68,18 +68,18 @@ public abstract class AuthorizationStrategy extends AbstractDescribableImpl * IOW, this ACL will have the ultimate say on the access control. */ - public abstract @Nonnull ACL getRootACL(); + public abstract @NonNull ACL getRootACL(); /** * @deprecated since 1.277 * Override {@link #getACL(Job)} instead. */ @Deprecated - public @Nonnull ACL getACL(@Nonnull AbstractProject project) { + public @NonNull ACL getACL(@NonNull AbstractProject project) { return getACL((Job)project); } - public @Nonnull ACL getACL(@Nonnull Job project) { + public @NonNull ACL getACL(@NonNull Job project) { return getRootACL(); } @@ -93,7 +93,7 @@ public abstract class AuthorizationStrategy extends AbstractDescribableImpl { ACL base = item.getOwner().getACL(); @@ -115,7 +115,7 @@ public abstract class AuthorizationStrategy extends AbstractDescribableImpl getGroups(); + public abstract @NonNull Collection getGroups(); /** * Returns all the registered {@link AuthorizationStrategy} descriptors. */ - public static @Nonnull DescriptorExtensionList> all() { + public static @NonNull DescriptorExtensionList> all() { return Jenkins.get().getDescriptorList(AuthorizationStrategy.class); } @@ -212,12 +212,12 @@ private Object readResolve() { } @Override - public @Nonnull ACL getRootACL() { + public @NonNull ACL getRootACL() { return UNSECURED_ACL; } @Override - public @Nonnull Collection getGroups() { + public @NonNull Collection getGroups() { return Collections.emptySet(); } @@ -231,7 +231,7 @@ public String getDisplayName() { } @Override - public @Nonnull AuthorizationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException { + public @NonNull AuthorizationStrategy newInstance(StaplerRequest req, JSONObject formData) throws FormException { return UNSECURED; } } diff --git a/core/src/main/java/hudson/security/FederatedLoginService.java b/core/src/main/java/hudson/security/FederatedLoginService.java index c659e66c21ac..e87b30af68ed 100644 --- a/core/src/main/java/hudson/security/FederatedLoginService.java +++ b/core/src/main/java/hudson/security/FederatedLoginService.java @@ -35,8 +35,8 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import java.io.IOException; import java.io.Serializable; @@ -101,14 +101,14 @@ public abstract class FederatedLoginService implements ExtensionPoint { * The object is bound to /federatedLoginService/URLNAME/. The url name needs to be unique among all * {@link FederatedLoginService}s. */ - @Nonnull + @NonNull public abstract String getUrlName(); /** * Returns your implementation of {@link FederatedLoginServiceUserProperty} that stores * opaque identifiers. */ - @Nonnull + @NonNull public abstract Class getUserPropertyClass(); /** @@ -121,7 +121,7 @@ public abstract class FederatedIdentity implements Serializable { * * @return must not be null. */ - @Nonnull + @NonNull public abstract String getIdentifier(); /** @@ -184,7 +184,7 @@ public final User locateUser() { * a user registration session (provided that {@link SecurityRealm} supports that.) */ @SuppressWarnings("ACL.impersonate") - @Nonnull + @NonNull public User signin() throws UnclaimedIdentityException { User u = locateUser(); if (u!=null) { diff --git a/core/src/main/java/hudson/security/GlobalSecurityConfiguration.java b/core/src/main/java/hudson/security/GlobalSecurityConfiguration.java index 7eaedadf4064..8befb0a77fb8 100644 --- a/core/src/main/java/hudson/security/GlobalSecurityConfiguration.java +++ b/core/src/main/java/hudson/security/GlobalSecurityConfiguration.java @@ -41,7 +41,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import jenkins.model.GlobalConfigurationCategory; @@ -94,7 +94,7 @@ public boolean isDisableRememberMe() { return Jenkins.get().isDisableRememberMe(); } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.SECURITY; diff --git a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java index a6a914b3a94c..c9d5479df4af 100644 --- a/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java +++ b/core/src/main/java/hudson/security/HudsonPrivateSecurityRealm.java @@ -68,7 +68,7 @@ import org.mindrot.jbcrypt.BCrypt; import org.springframework.dao.DataAccessException; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -482,7 +482,7 @@ private User createAccount(SignupInfo si) throws IOException { return user; } - private boolean containsOnlyAcceptableCharacters(@Nonnull String value){ + private boolean containsOnlyAcceptableCharacters(@NonNull String value){ if(ID_REGEX == null){ return value.matches(DEFAULT_ID_REGEX); }else{ @@ -772,7 +772,7 @@ public String getDescription() { return Messages.HudsonPrivateSecurityRealm_ManageUserLinks_Description(); } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.SECURITY; diff --git a/core/src/main/java/hudson/security/Permission.java b/core/src/main/java/hudson/security/Permission.java index 703c3016c7d9..c0de58cd1ab2 100644 --- a/core/src/main/java/hudson/security/Permission.java +++ b/core/src/main/java/hudson/security/Permission.java @@ -33,8 +33,8 @@ import java.util.List; import java.util.Set; import java.util.concurrent.CopyOnWriteArrayList; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jvnet.localizer.Localizable; @@ -56,14 +56,14 @@ public final class Permission { // break eclipse compilation //Override - public int compare(@Nonnull Permission one, @Nonnull Permission two) { + public int compare(@NonNull Permission one, @NonNull Permission two) { return one.getId().compareTo(two.getId()); } }; - public final @Nonnull Class owner; + public final @NonNull Class owner; - public final @Nonnull PermissionGroup group; + public final @NonNull PermissionGroup group; // if some plugin serialized old version of this class using XStream, `id` can be null private final @CheckForNull String id; @@ -77,7 +77,7 @@ public int compare(@Nonnull Permission one, @Nonnull Permission two) { *

* The expected naming convention is something like "BrowseWorkspace". */ - public final @Nonnull String name; + public final @NonNull String name; /** * Human-readable description of this permission. @@ -119,7 +119,7 @@ public int compare(@Nonnull Permission one, @Nonnull Permission two) { /** * Scopes that this permission is directly contained by. */ - private final @Nonnull Set scopes; + private final @NonNull Set scopes; /** * Defines a new permission. @@ -146,9 +146,9 @@ public int compare(@Nonnull Permission one, @Nonnull Permission two) { * See {@link #impliedBy}. * @throws IllegalStateException if this permission was already defined */ - public Permission(@Nonnull PermissionGroup group, @Nonnull String name, + public Permission(@NonNull PermissionGroup group, @NonNull String name, @CheckForNull Localizable description, @CheckForNull Permission impliedBy, boolean enable, - @Nonnull PermissionScope[] scopes) throws IllegalStateException { + @NonNull PermissionScope[] scopes) throws IllegalStateException { if(!JSONUtils.isJavaIdentifier(name)) throw new IllegalArgumentException(name+" is not a Java identifier"); this.owner = group.owner; @@ -164,8 +164,8 @@ public Permission(@Nonnull PermissionGroup group, @Nonnull String name, ALL.add(this); } - public Permission(@Nonnull PermissionGroup group, @Nonnull String name, - @CheckForNull Localizable description, @CheckForNull Permission impliedBy, @Nonnull PermissionScope scope) { + public Permission(@NonNull PermissionGroup group, @NonNull String name, + @CheckForNull Localizable description, @CheckForNull Permission impliedBy, @NonNull PermissionScope scope) { this(group,name,description,impliedBy,true,new PermissionScope[]{scope}); assert scope!=null; } @@ -175,7 +175,7 @@ public Permission(@Nonnull PermissionGroup group, @Nonnull String name, * Use {@link #Permission(PermissionGroup, String, Localizable, Permission, boolean, PermissionScope[])} */ @Deprecated - public Permission(@Nonnull PermissionGroup group, @Nonnull String name, @CheckForNull Localizable description, @CheckForNull Permission impliedBy, boolean enable) { + public Permission(@NonNull PermissionGroup group, @NonNull String name, @CheckForNull Localizable description, @CheckForNull Permission impliedBy, boolean enable) { this(group,name,description,impliedBy,enable,new PermissionScope[]{PermissionScope.JENKINS}); } @@ -184,7 +184,7 @@ public Permission(@Nonnull PermissionGroup group, @Nonnull String name, @CheckFo * Use {@link #Permission(PermissionGroup, String, Localizable, Permission, PermissionScope)} */ @Deprecated - public Permission(@Nonnull PermissionGroup group, @Nonnull String name, @CheckForNull Localizable description, @CheckForNull Permission impliedBy) { + public Permission(@NonNull PermissionGroup group, @NonNull String name, @CheckForNull Localizable description, @CheckForNull Permission impliedBy) { this(group, name, description, impliedBy, PermissionScope.JENKINS); } @@ -193,18 +193,18 @@ public Permission(@Nonnull PermissionGroup group, @Nonnull String name, @CheckFo * Use {@link #Permission(PermissionGroup, String, Localizable, Permission)} */ @Deprecated - public Permission(@Nonnull PermissionGroup group, @Nonnull String name, @CheckForNull Permission impliedBy) { + public Permission(@NonNull PermissionGroup group, @NonNull String name, @CheckForNull Permission impliedBy) { this(group,name,null,impliedBy); } - private Permission(@Nonnull PermissionGroup group, @Nonnull String name) { + private Permission(@NonNull PermissionGroup group, @NonNull String name) { this(group,name,null,null); } /** * Checks if this permission is contained in the specified scope, (either directly or indirectly.) */ - public boolean isContainedBy(@Nonnull PermissionScope s) { + public boolean isContainedBy(@NonNull PermissionScope s) { for (PermissionScope c : scopes) { if (c.isContainedBy(s)) return true; @@ -222,7 +222,7 @@ public boolean isContainedBy(@Nonnull PermissionScope s) { * @return ID with the following format: permissionClass.permissionName * @see #fromId(String) */ - public @Nonnull String getId() { + public @NonNull String getId() { if (id == null) { return owner.getName() + '.' + name; } @@ -244,7 +244,7 @@ public boolean isContainedBy(@Nonnull PermissionScope s) { * null if the conversion failed. * @see #getId() */ - public static @CheckForNull Permission fromId(@Nonnull String id) { + public static @CheckForNull Permission fromId(@NonNull String id) { int idx = id.lastIndexOf('.'); if(idx<0) return null; @@ -277,7 +277,7 @@ public boolean getEnabled() { * @return * always non-null. Read-only. */ - public static @Nonnull List getAll() { + public static @NonNull List getAll() { return ALL_VIEW; } diff --git a/core/src/main/java/hudson/security/PermissionGroup.java b/core/src/main/java/hudson/security/PermissionGroup.java index 891a3a5e0e5e..5ee861863f1d 100644 --- a/core/src/main/java/hudson/security/PermissionGroup.java +++ b/core/src/main/java/hudson/security/PermissionGroup.java @@ -30,8 +30,8 @@ import java.util.Locale; import java.util.SortedSet; import java.util.TreeSet; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jvnet.localizer.Localizable; @@ -43,7 +43,7 @@ public final class PermissionGroup implements Iterable, Comparable { private final SortedSet permissions = new TreeSet<>(Permission.ID_COMPARATOR); - @Nonnull + @NonNull public final Class owner; /** @@ -60,7 +60,7 @@ public final class PermissionGroup implements Iterable, Comparable

SYSTEM user has full access"); @@ -65,7 +65,7 @@ public boolean hasPermission(@Nonnull Authentication a, Permission permission) { * true or false if {@link #hasPermission(Sid, Permission)} returns it. * Otherwise null, indicating that this ACL doesn't have any entry for it. */ - protected Boolean _hasPermission(@Nonnull Authentication a, Permission permission) { + protected Boolean _hasPermission(@NonNull Authentication a, Permission permission) { // ACL entries for this principal takes precedence Boolean b = hasPermission(new PrincipalSid(a),permission); if(LOGGER.isLoggable(FINER)) diff --git a/core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java b/core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java index a6e5b312fac5..6d2957cba9a0 100644 --- a/core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java +++ b/core/src/main/java/hudson/security/TokenBasedRememberMeServices2.java @@ -41,8 +41,8 @@ import org.springframework.util.Assert; import org.springframework.util.StringUtils; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -288,7 +288,7 @@ private String findRememberMeCookieValue(HttpServletRequest request, HttpServlet /** * @return the decoded base64 of the cookie or {@code null} if the value was not correctly encoded */ - private @CheckForNull String decodeCookieBase64(@Nonnull String base64EncodedValue){ + private @CheckForNull String decodeCookieBase64(@NonNull String base64EncodedValue){ StringBuilder base64EncodedValueBuilder = new StringBuilder(base64EncodedValue); for (int j = 0; j < base64EncodedValueBuilder.length() % 4; j++) { base64EncodedValueBuilder.append("="); diff --git a/core/src/main/java/hudson/security/WhoAmI.java b/core/src/main/java/hudson/security/WhoAmI.java index 816e0a3f77be..35f1e99b9ef2 100644 --- a/core/src/main/java/hudson/security/WhoAmI.java +++ b/core/src/main/java/hudson/security/WhoAmI.java @@ -24,7 +24,7 @@ import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.export.ExportedBean; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Expose the data needed for /whoAmI, so it can be exposed by Api. @@ -70,7 +70,7 @@ public String getToString() { return auth().toString(); } - private @Nonnull Authentication auth() { + private @NonNull Authentication auth() { return Jenkins.getAuthentication(); } @@ -88,7 +88,7 @@ public String[] getAuthorities() { // Used by Jelly @Restricted(NoExternalUse.class) - public boolean isHeaderDangerous(@Nonnull String name) { + public boolean isHeaderDangerous(@NonNull String name) { return dangerousHeaders.contains(name.toLowerCase(Locale.ENGLISH)); } diff --git a/core/src/main/java/hudson/security/csrf/GlobalCrumbIssuerConfiguration.java b/core/src/main/java/hudson/security/csrf/GlobalCrumbIssuerConfiguration.java index d14e7b3bd48c..3c44b6c73de2 100644 --- a/core/src/main/java/hudson/security/csrf/GlobalCrumbIssuerConfiguration.java +++ b/core/src/main/java/hudson/security/csrf/GlobalCrumbIssuerConfiguration.java @@ -34,7 +34,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Show the crumb configuration to the system config page. @@ -44,7 +44,7 @@ @Extension(ordinal=195) @Symbol("crumb") // immediately after the security setting public class GlobalCrumbIssuerConfiguration extends GlobalConfiguration { @Override - public @Nonnull GlobalConfigurationCategory getCategory() { + public @NonNull GlobalConfigurationCategory getCategory() { return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Security.class); } diff --git a/core/src/main/java/hudson/slaves/AbstractCloudComputer.java b/core/src/main/java/hudson/slaves/AbstractCloudComputer.java index 4dc3a71a72c6..51bb33d84c5d 100644 --- a/core/src/main/java/hudson/slaves/AbstractCloudComputer.java +++ b/core/src/main/java/hudson/slaves/AbstractCloudComputer.java @@ -30,7 +30,7 @@ import org.kohsuke.stapler.interceptor.RequirePOST; import java.io.IOException; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Partial implementation of {@link Computer} to be used in conjunction with diff --git a/core/src/main/java/hudson/slaves/AbstractCloudSlave.java b/core/src/main/java/hudson/slaves/AbstractCloudSlave.java index 3787d57c6f79..228832297fea 100644 --- a/core/src/main/java/hudson/slaves/AbstractCloudSlave.java +++ b/core/src/main/java/hudson/slaves/AbstractCloudSlave.java @@ -30,7 +30,7 @@ import hudson.model.TaskListener; import hudson.util.StreamTaskListener; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.nio.charset.Charset; import java.util.List; @@ -45,7 +45,7 @@ */ public abstract class AbstractCloudSlave extends Slave { - public AbstractCloudSlave(@Nonnull String name, String remoteFS, ComputerLauncher launcher) + public AbstractCloudSlave(@NonNull String name, String remoteFS, ComputerLauncher launcher) throws FormException, IOException { super(name, remoteFS, launcher); } diff --git a/core/src/main/java/hudson/slaves/ChannelPinger.java b/core/src/main/java/hudson/slaves/ChannelPinger.java index d92ef1bff97f..7aa5b9b5f75a 100644 --- a/core/src/main/java/hudson/slaves/ChannelPinger.java +++ b/core/src/main/java/hudson/slaves/ChannelPinger.java @@ -37,7 +37,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.io.IOException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; diff --git a/core/src/main/java/hudson/slaves/Cloud.java b/core/src/main/java/hudson/slaves/Cloud.java index c1ef326612f9..9eeb4ad1d736 100644 --- a/core/src/main/java/hudson/slaves/Cloud.java +++ b/core/src/main/java/hudson/slaves/Cloud.java @@ -42,7 +42,7 @@ import hudson.util.DescriptorList; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.Collection; import java.util.concurrent.Future; @@ -112,11 +112,11 @@ public String getDisplayName() { * @since 2.64 * @return Jenkins relative URL. */ - public @Nonnull String getUrl() { + public @NonNull String getUrl() { return "cloud/" + name; } - public @Nonnull String getSearchUrl() { + public @NonNull String getSearchUrl() { return getUrl(); } diff --git a/core/src/main/java/hudson/slaves/CloudProvisioningListener.java b/core/src/main/java/hudson/slaves/CloudProvisioningListener.java index 0c5d1bcbeb52..a25433191e53 100644 --- a/core/src/main/java/hudson/slaves/CloudProvisioningListener.java +++ b/core/src/main/java/hudson/slaves/CloudProvisioningListener.java @@ -10,7 +10,7 @@ import java.util.Collection; import java.util.concurrent.Future; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Allows extensions to be notified of events in any {@link Cloud} and to prevent @@ -73,7 +73,7 @@ public void onComplete(NodeProvisioner.PlannedNode plannedNode, Node node) { * * @since 2.37 */ - public void onCommit(@Nonnull NodeProvisioner.PlannedNode plannedNode, @Nonnull Node node) { + public void onCommit(@NonNull NodeProvisioner.PlannedNode plannedNode, @NonNull Node node) { // Noop by default } @@ -96,8 +96,8 @@ public void onFailure(NodeProvisioner.PlannedNode plannedNode, Throwable t) { * * @since 2.37 */ - public void onRollback(@Nonnull NodeProvisioner.PlannedNode plannedNode, @Nonnull Node node, - @Nonnull Throwable t) { + public void onRollback(@NonNull NodeProvisioner.PlannedNode plannedNode, @NonNull Node node, + @NonNull Throwable t) { // Noop by default } diff --git a/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java b/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java index 852f38d6893a..2e60f983d986 100644 --- a/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java +++ b/core/src/main/java/hudson/slaves/CloudRetentionStrategy.java @@ -25,7 +25,7 @@ import jenkins.util.SystemProperties; -import javax.annotation.concurrent.GuardedBy; +import net.jcip.annotations.GuardedBy; import java.io.IOException; import java.util.logging.Logger; diff --git a/core/src/main/java/hudson/slaves/CloudSlaveRetentionStrategy.java b/core/src/main/java/hudson/slaves/CloudSlaveRetentionStrategy.java index e14d934801f9..c90667892e48 100644 --- a/core/src/main/java/hudson/slaves/CloudSlaveRetentionStrategy.java +++ b/core/src/main/java/hudson/slaves/CloudSlaveRetentionStrategy.java @@ -5,7 +5,7 @@ import java.util.concurrent.TimeUnit; import jenkins.model.Jenkins; -import javax.annotation.concurrent.GuardedBy; +import net.jcip.annotations.GuardedBy; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/core/src/main/java/hudson/slaves/ComputerConnector.java b/core/src/main/java/hudson/slaves/ComputerConnector.java index cc2ed123953a..817f61d6f674 100644 --- a/core/src/main/java/hudson/slaves/ComputerConnector.java +++ b/core/src/main/java/hudson/slaves/ComputerConnector.java @@ -28,7 +28,7 @@ import hudson.model.TaskListener; import java.io.IOException; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Factory of {@link ComputerLauncher}. @@ -49,7 +49,7 @@ public abstract class ComputerConnector extends AbstractDescribableImpl * @since 2.12 */ public List> applicableDescriptors(@CheckForNull Slave it, - @Nonnull Slave.SlaveDescriptor itDescriptor) { + @NonNull Slave.SlaveDescriptor itDescriptor) { List> r = new ArrayList<>(); for (Descriptor d : itDescriptor.computerLauncherDescriptors(it)) { if (DelegatingComputerLauncher.class.isAssignableFrom(d.getKlass().toJavaClass())) continue; diff --git a/core/src/main/java/hudson/slaves/DumbSlave.java b/core/src/main/java/hudson/slaves/DumbSlave.java index af1cc47dc17e..153477c8ac42 100644 --- a/core/src/main/java/hudson/slaves/DumbSlave.java +++ b/core/src/main/java/hudson/slaves/DumbSlave.java @@ -34,7 +34,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Default {@link Slave} implementation for computers that do not belong to a higher level structure, @@ -62,7 +62,7 @@ public DumbSlave(String name, String nodeDescription, String remoteFS, String nu } @DataBoundConstructor - public DumbSlave(@Nonnull String name, String remoteFS, ComputerLauncher launcher) throws FormException, IOException { + public DumbSlave(@NonNull String name, String remoteFS, ComputerLauncher launcher) throws FormException, IOException { super(name, remoteFS, launcher); } diff --git a/core/src/main/java/hudson/slaves/JNLPLauncher.java b/core/src/main/java/hudson/slaves/JNLPLauncher.java index ae8dab48f50e..c15d125b5e15 100644 --- a/core/src/main/java/hudson/slaves/JNLPLauncher.java +++ b/core/src/main/java/hudson/slaves/JNLPLauncher.java @@ -29,8 +29,8 @@ import hudson.model.Descriptor; import hudson.model.TaskListener; import hudson.util.FormValidation; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import jenkins.slaves.RemotingWorkDirSettings; @@ -71,7 +71,7 @@ public class JNLPLauncher extends ComputerLauncher { @CheckForNull public final String vmargs; - @Nonnull + @NonNull private RemotingWorkDirSettings workDirSettings = RemotingWorkDirSettings.getEnabledDefaults(); private boolean webSocket; @@ -132,13 +132,13 @@ protected Object readResolve() { * * @since 2.72 */ - @Nonnull + @NonNull public RemotingWorkDirSettings getWorkDirSettings() { return workDirSettings; } @DataBoundSetter - public final void setWorkDirSettings(@Nonnull RemotingWorkDirSettings workDirSettings) { + public final void setWorkDirSettings(@NonNull RemotingWorkDirSettings workDirSettings) { this.workDirSettings = workDirSettings; } @@ -181,9 +181,9 @@ public void launch(SlaveComputer computer, TaskListener listener) { * @param computer Computer * @return Command line options for launching with the WorkDir */ - @Nonnull + @NonNull @Restricted(NoExternalUse.class) - public String getWorkDirOptions(@Nonnull Computer computer) { + public String getWorkDirOptions(@NonNull Computer computer) { if(!(computer instanceof SlaveComputer)) { return ""; } diff --git a/core/src/main/java/hudson/slaves/NodeList.java b/core/src/main/java/hudson/slaves/NodeList.java index 87f7a82328b7..30e842c600a2 100644 --- a/core/src/main/java/hudson/slaves/NodeList.java +++ b/core/src/main/java/hudson/slaves/NodeList.java @@ -39,7 +39,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * {@link CopyOnWriteArrayList} for {@link Node} that has special serialization semantics diff --git a/core/src/main/java/hudson/slaves/NodeProperty.java b/core/src/main/java/hudson/slaves/NodeProperty.java index a24b343b7b8e..324b089f43ea 100644 --- a/core/src/main/java/hudson/slaves/NodeProperty.java +++ b/core/src/main/java/hudson/slaves/NodeProperty.java @@ -47,7 +47,7 @@ import java.io.IOException; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Extensible property of {@link Node}. @@ -166,7 +166,7 @@ public Environment setUp( AbstractBuild build, Launcher launcher, BuildListener * * @since 1.489 */ - public void buildEnvVars(@Nonnull EnvVars env, @Nonnull TaskListener listener) throws IOException,InterruptedException { + public void buildEnvVars(@NonNull EnvVars env, @NonNull TaskListener listener) throws IOException,InterruptedException { // default is no-op } diff --git a/core/src/main/java/hudson/slaves/NodeProvisioner.java b/core/src/main/java/hudson/slaves/NodeProvisioner.java index acabe894bae8..2a03bad8e399 100644 --- a/core/src/main/java/hudson/slaves/NodeProvisioner.java +++ b/core/src/main/java/hudson/slaves/NodeProvisioner.java @@ -35,9 +35,9 @@ import jenkins.util.Timer; import org.jenkinsci.Symbol; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.GuardedBy; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import net.jcip.annotations.GuardedBy; import java.awt.Color; import java.util.Arrays; import java.util.Collections; @@ -382,9 +382,9 @@ public static abstract class Strategy implements ExtensionPoint { * @param state the current state. * @return the decision. */ - @Nonnull + @NonNull @GuardedBy("NodeProvisioner.this") - public abstract StrategyDecision apply(@Nonnull StrategyState state); + public abstract StrategyDecision apply(@NonNull StrategyState state); } @@ -631,9 +631,9 @@ public String toString() { @Extension @Symbol("standard") public static class StandardStrategyImpl extends Strategy { - @Nonnull + @NonNull @Override - public StrategyDecision apply(@Nonnull StrategyState state) { + public StrategyDecision apply(@NonNull StrategyState state) { /* Here we determine how many additional agents we need to keep up with the load (if at all), which involves a simple math. diff --git a/core/src/main/java/hudson/slaves/NodeSpecific.java b/core/src/main/java/hudson/slaves/NodeSpecific.java index e40ef509dfaf..a59230cf9291 100644 --- a/core/src/main/java/hudson/slaves/NodeSpecific.java +++ b/core/src/main/java/hudson/slaves/NodeSpecific.java @@ -28,7 +28,7 @@ import hudson.model.EnvironmentSpecific; import hudson.model.TaskListener; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; /** @@ -46,5 +46,5 @@ public interface NodeSpecific> { /** * Returns a specialized copy of T for functioning in the given node. */ - T forNode(@Nonnull Node node, TaskListener log) throws IOException, InterruptedException; + T forNode(@NonNull Node node, TaskListener log) throws IOException, InterruptedException; } diff --git a/core/src/main/java/hudson/slaves/OfflineCause.java b/core/src/main/java/hudson/slaves/OfflineCause.java index a158ce2b8c15..cf9901739998 100644 --- a/core/src/main/java/hudson/slaves/OfflineCause.java +++ b/core/src/main/java/hudson/slaves/OfflineCause.java @@ -33,8 +33,8 @@ import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.export.Exported; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.ObjectStreamException; import java.util.Collections; import java.util.Date; @@ -70,7 +70,7 @@ public long getTimestamp() { * * @since 1.612 */ - public final @Nonnull Date getTime() { + public final @NonNull Date getTime() { return new Date(timestamp); } diff --git a/core/src/main/java/hudson/slaves/RetentionStrategy.java b/core/src/main/java/hudson/slaves/RetentionStrategy.java index 6cc0787afbe4..14d8631de71e 100644 --- a/core/src/main/java/hudson/slaves/RetentionStrategy.java +++ b/core/src/main/java/hudson/slaves/RetentionStrategy.java @@ -35,11 +35,11 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.concurrent.GuardedBy; +import net.jcip.annotations.GuardedBy; import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Controls when to take {@link Computer} offline, bring it back online, or even to destroy it. @@ -58,7 +58,7 @@ public abstract class RetentionStrategy extends AbstractDesc * rechecked earlier or later than this! */ @GuardedBy("hudson.model.Queue.lock") - public abstract long check(@Nonnull T c); + public abstract long check(@NonNull T c); /** * This method is called to determine whether manual launching of the agent is allowed right now. @@ -96,7 +96,7 @@ public boolean isAcceptingTasks(T c) { * @param c Computer instance * @since 1.275 */ - public void start(final @Nonnull T c) { + public void start(final @NonNull T c) { Queue.withLock((Runnable) () -> check(c)); } diff --git a/core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java b/core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java index df9ff8ce07da..ea7b9211316e 100644 --- a/core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java +++ b/core/src/main/java/hudson/slaves/SimpleScheduledRetentionStrategy.java @@ -35,7 +35,7 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; -import javax.annotation.concurrent.GuardedBy; +import net.jcip.annotations.GuardedBy; import java.io.InvalidObjectException; import java.io.ObjectStreamException; import java.util.Calendar; diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index 4c59ec8aaeef..91ba910d7b51 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -75,10 +75,10 @@ import org.kohsuke.stapler.export.Exported; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.CheckForNull; -import javax.annotation.CheckReturnValue; -import javax.annotation.Nonnull; -import javax.annotation.OverridingMethodsMustInvokeSuper; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckReturnValue; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.OverrideMustInvoke; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -171,7 +171,7 @@ private OutputStream decorate(OutputStream os) { } @Override - @OverridingMethodsMustInvokeSuper + @OverrideMustInvoke public boolean isAcceptingTasks() { // our boolean flag is an override on any additional programmatic reasons why this agent might not be // accepting tasks. @@ -380,8 +380,8 @@ public OutputStream openLogFile() { * Same as {@link #setChannel(InputStream, OutputStream, OutputStream, Channel.Listener)}, but for * {@link TaskListener}. */ - public void setChannel(@Nonnull InputStream in, @Nonnull OutputStream out, - @Nonnull TaskListener taskListener, + public void setChannel(@NonNull InputStream in, @NonNull OutputStream out, + @NonNull TaskListener taskListener, @CheckForNull Channel.Listener listener) throws IOException, InterruptedException { setChannel(in,out,taskListener.getLogger(),listener); } @@ -405,7 +405,7 @@ public void setChannel(@Nonnull InputStream in, @Nonnull OutputStream out, * By the time this method is called, the cause of the termination is reported to the user, * so the implementation of the listener doesn't need to do that again. */ - public void setChannel(@Nonnull InputStream in, @Nonnull OutputStream out, + public void setChannel(@NonNull InputStream in, @NonNull OutputStream out, @CheckForNull OutputStream launchLog, @CheckForNull Channel.Listener listener) throws IOException, InterruptedException { ChannelBuilder cb = new ChannelBuilder(nodeName,threadPoolForRemoting) @@ -437,8 +437,8 @@ public void setChannel(@Nonnull InputStream in, @Nonnull OutputStream out, * @since 2.127 */ @Restricted(Beta.class) - public void setChannel(@Nonnull ChannelBuilder cb, - @Nonnull CommandTransport commandTransport, + public void setChannel(@NonNull ChannelBuilder cb, + @NonNull CommandTransport commandTransport, @CheckForNull Channel.Listener listener) throws IOException, InterruptedException { for (ChannelConfigurator cc : ChannelConfigurator.all()) { cc.onChannelBuilding(cb,this); @@ -599,7 +599,7 @@ static class LoadingTime extends MasterToSlaveCallable { * @param listener Channel event listener to be attached (if not {@code null}) * @since 1.444 */ - public void setChannel(@Nonnull Channel channel, + public void setChannel(@NonNull Channel channel, @CheckForNull OutputStream launchLog, @CheckForNull Channel.Listener listener) throws IOException, InterruptedException { if(this.channel!=null) diff --git a/core/src/main/java/hudson/slaves/WorkspaceList.java b/core/src/main/java/hudson/slaves/WorkspaceList.java index ec05886aae5c..8afd10b414c8 100644 --- a/core/src/main/java/hudson/slaves/WorkspaceList.java +++ b/core/src/main/java/hudson/slaves/WorkspaceList.java @@ -36,8 +36,8 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Used by {@link Computer} to keep track of workspaces that are actively in use. @@ -78,7 +78,7 @@ public static final class Entry { */ public final boolean quick; - public final @Nonnull FilePath path; + public final @NonNull FilePath path; /** * Multiple threads can acquire the same lock if they share the same context object. @@ -87,11 +87,11 @@ public static final class Entry { public int lockCount=1; - private Entry(@Nonnull FilePath path, boolean quick) { + private Entry(@NonNull FilePath path, boolean quick) { this(path,quick,new Object()); // unique context } - private Entry(@Nonnull FilePath path, boolean quick, Object context) { + private Entry(@NonNull FilePath path, boolean quick, Object context) { this.path = path; this.quick = quick; this.context = context; @@ -110,9 +110,9 @@ public String toString() { * Represents a leased workspace that needs to be returned later. */ public static abstract class Lease implements /*Auto*/Closeable { - public final @Nonnull FilePath path; + public final @NonNull FilePath path; - protected Lease(@Nonnull FilePath path) { + protected Lease(@NonNull FilePath path) { if (path == null) { // Protection from old API throw new NullPointerException("The specified FilePath is null"); } @@ -135,7 +135,7 @@ protected Lease(@Nonnull FilePath path) { /** * Creates a dummy {@link Lease} object that does no-op in the release. */ - public static Lease createDummyLease(@Nonnull FilePath p) { + public static Lease createDummyLease(@NonNull FilePath p) { return new Lease(p) { public void release() { // noop @@ -147,7 +147,7 @@ public void release() { * Creates a {@link Lease} object that points to the specified path, but the lock * is controlled by the given parent lease object. */ - public static Lease createLinkedDummyLease(@Nonnull FilePath p, final Lease parent) { + public static Lease createLinkedDummyLease(@NonNull FilePath p, final Lease parent) { return new Lease(p) { public void release() { parent.release(); @@ -168,7 +168,7 @@ public WorkspaceList() { * This method doesn't block prolonged amount of time. Whenever a desired workspace * is in use, the unique variation is added. */ - public synchronized Lease allocate(@Nonnull FilePath base) throws InterruptedException { + public synchronized Lease allocate(@NonNull FilePath base) throws InterruptedException { return allocate(base,new Object()); } @@ -179,7 +179,7 @@ public synchronized Lease allocate(@Nonnull FilePath base) throws InterruptedExc * Threads that share the same context can re-acquire the same lock (which will just increment the lock count.) * This allows related executors to share the same workspace. */ - public synchronized Lease allocate(@Nonnull FilePath base, Object context) throws InterruptedException { + public synchronized Lease allocate(@NonNull FilePath base, Object context) throws InterruptedException { for (int i=1; ; i++) { FilePath candidate = i==1 ? base : base.withSuffix(COMBINATOR+i); Entry e = inUse.get(candidate.getRemote()); @@ -192,7 +192,7 @@ public synchronized Lease allocate(@Nonnull FilePath base, Object context) throw /** * Just record that this workspace is being used, without paying any attention to the synchronization support. */ - public synchronized Lease record(@Nonnull FilePath p) { + public synchronized Lease record(@NonNull FilePath p) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "recorded " + p, new Throwable("from " + this)); } @@ -205,7 +205,7 @@ public synchronized Lease record(@Nonnull FilePath p) { /** * Releases an allocated or acquired workspace. */ - private synchronized void _release(@Nonnull FilePath p) { + private synchronized void _release(@NonNull FilePath p) { Entry old = inUse.get(p.getRemote()); if (old==null) throw new AssertionError("Releasing unallocated workspace "+p); @@ -224,7 +224,7 @@ private synchronized void _release(@Nonnull FilePath p) { * @return * The same {@link FilePath} as given to this method. */ - public synchronized Lease acquire(@Nonnull FilePath p) throws InterruptedException { + public synchronized Lease acquire(@NonNull FilePath p) throws InterruptedException { return acquire(p,false); } @@ -235,7 +235,7 @@ public synchronized Lease acquire(@Nonnull FilePath p) throws InterruptedExcepti * If true, indicates that the acquired workspace will be returned quickly. * This makes other calls to {@link #allocate(FilePath)} to wait for the release of this workspace. */ - public synchronized Lease acquire(@Nonnull FilePath p, boolean quick) throws InterruptedException { + public synchronized Lease acquire(@NonNull FilePath p, boolean quick) throws InterruptedException { return acquire(p,quick,new Object()); } @@ -246,7 +246,7 @@ public synchronized Lease acquire(@Nonnull FilePath p, boolean quick) throws Int * Threads that share the same context can re-acquire the same lock (which will just increment the lock count.) * This allows related executors to share the same workspace. */ - public synchronized Lease acquire(@Nonnull FilePath p, boolean quick, Object context) throws InterruptedException { + public synchronized Lease acquire(@NonNull FilePath p, boolean quick, Object context) throws InterruptedException { Entry e; Thread t = Thread.currentThread(); @@ -274,7 +274,7 @@ public synchronized Lease acquire(@Nonnull FilePath p, boolean quick, Object con /** * Wraps a path into a valid lease. */ - private Lease lease(@Nonnull FilePath p) { + private Lease lease(@NonNull FilePath p) { return new Lease(p) { final AtomicBoolean released = new AtomicBoolean(); public void release() { diff --git a/core/src/main/java/hudson/tasks/ArtifactArchiver.java b/core/src/main/java/hudson/tasks/ArtifactArchiver.java index de80af32c8a1..c379d69bd0bf 100644 --- a/core/src/main/java/hudson/tasks/ArtifactArchiver.java +++ b/core/src/main/java/hudson/tasks/ArtifactArchiver.java @@ -53,10 +53,10 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import net.sf.json.JSONObject; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.BuildDiscarder; import jenkins.model.Jenkins; import jenkins.tasks.SimpleBuildStep; @@ -88,7 +88,7 @@ public class ArtifactArchiver extends Recorder implements SimpleBuildStep { /** * Fail (or not) the build if archiving returns nothing. */ - @Nonnull + @NonNull private Boolean allowEmptyArchive; /** @@ -101,19 +101,19 @@ public class ArtifactArchiver extends Recorder implements SimpleBuildStep { /** * Default ant exclusion */ - @Nonnull + @NonNull private Boolean defaultExcludes = true; /** * Indicate whether include and exclude patterns should be considered as case sensitive */ - @Nonnull + @NonNull private Boolean caseSensitive = true; /** * Indicate whether symbolic links should be followed or not */ - @Nonnull + @NonNull private Boolean followSymlinks = true; @DataBoundConstructor public ArtifactArchiver(String artifacts) { diff --git a/core/src/main/java/hudson/tasks/BatchFile.java b/core/src/main/java/hudson/tasks/BatchFile.java index f390b0880d14..41748202368c 100644 --- a/core/src/main/java/hudson/tasks/BatchFile.java +++ b/core/src/main/java/hudson/tasks/BatchFile.java @@ -38,7 +38,7 @@ import java.io.ObjectStreamException; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Executes commands by using Windows batch file. diff --git a/core/src/main/java/hudson/tasks/BuildStep.java b/core/src/main/java/hudson/tasks/BuildStep.java index 600b419a1ab7..2af5f84c0584 100644 --- a/core/src/main/java/hudson/tasks/BuildStep.java +++ b/core/src/main/java/hudson/tasks/BuildStep.java @@ -49,7 +49,7 @@ import jenkins.security.QueueItemAuthenticator; import org.acegisecurity.Authentication; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; /** @@ -157,7 +157,7 @@ public interface BuildStep { * @return * can be empty but never null. */ - @Nonnull + @NonNull Collection getProjectActions(AbstractProject project); diff --git a/core/src/main/java/hudson/tasks/BuildStepCompatibilityLayer.java b/core/src/main/java/hudson/tasks/BuildStepCompatibilityLayer.java index dadcc90a8168..7d7c6422d4c9 100644 --- a/core/src/main/java/hudson/tasks/BuildStepCompatibilityLayer.java +++ b/core/src/main/java/hudson/tasks/BuildStepCompatibilityLayer.java @@ -42,7 +42,7 @@ import hudson.model.TaskListener; import jenkins.tasks.SimpleBuildStep; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Provides compatibility with {@link BuildStep} before 1.150 @@ -92,7 +92,7 @@ public Action getProjectAction(AbstractProject project) { return null; } - @Nonnull + @NonNull public Collection getProjectActions(AbstractProject project) { // delegate to getJobAction (singular) for backward compatible behavior Action a = getProjectAction(project); diff --git a/core/src/main/java/hudson/tasks/BuildTrigger.java b/core/src/main/java/hudson/tasks/BuildTrigger.java index aad8f36a44cb..aaa32b12b6f4 100644 --- a/core/src/main/java/hudson/tasks/BuildTrigger.java +++ b/core/src/main/java/hudson/tasks/BuildTrigger.java @@ -57,8 +57,8 @@ import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.DependencyDeclarer; import jenkins.model.Jenkins; import jenkins.model.ParameterizedJobMixIn; @@ -160,8 +160,8 @@ public List getChildProjects(ItemGroup base) { } @SuppressWarnings("unchecked") - @Nonnull - public List> getChildJobs(@Nonnull AbstractProject owner) { + @NonNull + public List> getChildJobs(@NonNull AbstractProject owner) { return Items.fromNameList(owner.getParent(), childProjects, (Class>) (Class) Job.class); } diff --git a/core/src/main/java/hudson/tasks/CommandInterpreter.java b/core/src/main/java/hudson/tasks/CommandInterpreter.java index 2b7908fdfa83..64160f291504 100644 --- a/core/src/main/java/hudson/tasks/CommandInterpreter.java +++ b/core/src/main/java/hudson/tasks/CommandInterpreter.java @@ -40,7 +40,7 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Common part between {@link Shell} and {@link BatchFile}. @@ -158,7 +158,7 @@ protected int join(Proc p) throws IOException, InterruptedException { /** * Creates a script file in a temporary name in the specified directory. */ - public FilePath createScriptFile(@Nonnull FilePath dir) throws IOException, InterruptedException { + public FilePath createScriptFile(@NonNull FilePath dir) throws IOException, InterruptedException { return dir.createTextTempFile("jenkins", getFileExtension(), getContents(), false); } diff --git a/core/src/main/java/hudson/tasks/Maven.java b/core/src/main/java/hudson/tasks/Maven.java index 1c17e767eae4..438c51356220 100644 --- a/core/src/main/java/hudson/tasks/Maven.java +++ b/core/src/main/java/hudson/tasks/Maven.java @@ -69,7 +69,7 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.File; import java.io.IOException; import java.io.ObjectStreamException; @@ -150,7 +150,7 @@ public class Maven extends Builder { * * @since 2.12 */ - private @Nonnull Boolean injectBuildVariables; + private @NonNull Boolean injectBuildVariables; private final static String MAVEN_1_INSTALLATION_COMMON_FILE = "bin/maven"; private final static String MAVEN_2_INSTALLATION_COMMON_FILE = "bin/mvn"; diff --git a/core/src/main/java/hudson/tasks/Shell.java b/core/src/main/java/hudson/tasks/Shell.java index 571a68c43956..1aa1502f0404 100644 --- a/core/src/main/java/hudson/tasks/Shell.java +++ b/core/src/main/java/hudson/tasks/Shell.java @@ -50,7 +50,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Executes a series of commands by using a shell. diff --git a/core/src/main/java/hudson/tasks/UserAvatarResolver.java b/core/src/main/java/hudson/tasks/UserAvatarResolver.java index 491f9d29adf5..b022c7a12653 100644 --- a/core/src/main/java/hudson/tasks/UserAvatarResolver.java +++ b/core/src/main/java/hudson/tasks/UserAvatarResolver.java @@ -33,7 +33,7 @@ import hudson.ExtensionPoint; import hudson.Functions; import hudson.model.User; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Infers avatar image URLs for users diff --git a/core/src/main/java/hudson/tools/ToolDescriptor.java b/core/src/main/java/hudson/tools/ToolDescriptor.java index fd9d4f644391..2ea93b2a7378 100644 --- a/core/src/main/java/hudson/tools/ToolDescriptor.java +++ b/core/src/main/java/hudson/tools/ToolDescriptor.java @@ -44,7 +44,7 @@ import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * {@link Descriptor} for {@link ToolInstallation}. @@ -116,7 +116,7 @@ public List getPropertyDescriptors() { @Override - public @Nonnull GlobalConfigurationCategory getCategory() { + public @NonNull GlobalConfigurationCategory getCategory() { return GlobalConfigurationCategory.get(ToolConfigurationCategory.class); } diff --git a/core/src/main/java/hudson/tools/ToolInstallation.java b/core/src/main/java/hudson/tools/ToolInstallation.java index 85387795c06e..df7e30f69f26 100644 --- a/core/src/main/java/hudson/tools/ToolInstallation.java +++ b/core/src/main/java/hudson/tools/ToolInstallation.java @@ -40,8 +40,8 @@ import com.thoughtworks.xstream.annotations.XStreamSerializable; import com.thoughtworks.xstream.converters.UnmarshallingContext; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; /** @@ -165,7 +165,7 @@ public DescribableList,ToolPropertyDescriptor> getProperties() { * @see EnvironmentSpecific * @since 1.460 */ - public ToolInstallation translate(@Nonnull Node node, EnvVars envs, TaskListener listener) throws IOException, InterruptedException { + public ToolInstallation translate(@NonNull Node node, EnvVars envs, TaskListener listener) throws IOException, InterruptedException { ToolInstallation t = this; if (t instanceof NodeSpecific) { NodeSpecific n = (NodeSpecific) t; diff --git a/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java b/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java index 131181c0be88..42ae6c88ccb2 100644 --- a/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java +++ b/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java @@ -11,7 +11,7 @@ import org.kohsuke.stapler.HttpResponses; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; @@ -25,15 +25,15 @@ @Extension public class SlowTriggerAdminMonitor extends AdministrativeMonitor { - @Nonnull + @NonNull private final Map errors = new ConcurrentHashMap<>(); public static int MAX_ENTRIES = 10; - @Nonnull + @NonNull private static final Logger LOGGER = Logger.getLogger(SlowTriggerAdminMonitor.class.getName()); - @Nonnull + @NonNull public static SlowTriggerAdminMonitor getInstance() { return ExtensionList.lookup(SlowTriggerAdminMonitor.class).get(0); } @@ -47,7 +47,7 @@ public boolean isActivated() { } @Override - @Nonnull + @NonNull public String getDisplayName() { return Messages.SlowTriggerAdminMonitor_DisplayName(); } @@ -58,7 +58,7 @@ public void clear() { } } - public void report(@Nonnull final String trigger, @Nonnull final String msg) { + public void report(@NonNull final String trigger, @NonNull final String msg) { synchronized (errors) { if (errors.size() >= MAX_ENTRIES && !errors.containsKey(trigger)) { @@ -78,14 +78,14 @@ public void report(@Nonnull final String trigger, @Nonnull final String msg) { errors.put(trigger, new Value(msg)); } - @Nonnull + @NonNull public Map getErrors() { return new HashMap<>(errors); } @Restricted(DoNotUse.class) @RequirePOST - @Nonnull + @NonNull public HttpResponse doClear() throws IOException { Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER); clear(); @@ -97,22 +97,22 @@ public class Value { private final LocalDateTime time; private final String msg; - Value(@Nonnull String msg) { + Value(@NonNull String msg) { this.msg = msg; this.time = LocalDateTime.now(); } - @Nonnull + @NonNull public String getTime() { return DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).format(time); } - @Nonnull + @NonNull protected LocalDateTime getTimeLDT() { return time; } - @Nonnull + @NonNull public String getMsg() { return msg; } diff --git a/core/src/main/java/hudson/triggers/TimerTrigger.java b/core/src/main/java/hudson/triggers/TimerTrigger.java index da844fa6b6be..5085caf1d266 100644 --- a/core/src/main/java/hudson/triggers/TimerTrigger.java +++ b/core/src/main/java/hudson/triggers/TimerTrigger.java @@ -44,7 +44,7 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * {@link Trigger} that runs a job periodically. @@ -54,7 +54,7 @@ public class TimerTrigger extends Trigger { @DataBoundConstructor - public TimerTrigger(@Nonnull String spec) throws ANTLRException { + public TimerTrigger(@NonNull String spec) throws ANTLRException { super(spec); } diff --git a/core/src/main/java/hudson/triggers/Trigger.java b/core/src/main/java/hudson/triggers/Trigger.java index ae7ad4bba472..647d445a4185 100644 --- a/core/src/main/java/hudson/triggers/Trigger.java +++ b/core/src/main/java/hudson/triggers/Trigger.java @@ -58,8 +58,8 @@ import java.util.logging.Logger; import antlr.ANTLRException; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.Items; import jenkins.model.ParameterizedJobMixIn; @@ -165,7 +165,7 @@ public TriggerDescriptor getDescriptor() { * periodically. This is useful when your trigger does * some polling work. */ - protected Trigger(@Nonnull String cronTabSpec) throws ANTLRException { + protected Trigger(@NonNull String cronTabSpec) throws ANTLRException { this.spec = cronTabSpec; this.tabs = CronTabList.create(cronTabSpec); } diff --git a/core/src/main/java/hudson/util/ArgumentListBuilder.java b/core/src/main/java/hudson/util/ArgumentListBuilder.java index 39e19adcbe32..9a5a037fe0a7 100644 --- a/core/src/main/java/hudson/util/ArgumentListBuilder.java +++ b/core/src/main/java/hudson/util/ArgumentListBuilder.java @@ -39,7 +39,7 @@ import java.io.File; import java.io.IOException; import java.util.Set; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Used to build up arguments for a process invocation. @@ -138,7 +138,7 @@ public ArgumentListBuilder add(String... args) { /** * @since 2.72 */ - public ArgumentListBuilder add(@Nonnull Iterable args) { + public ArgumentListBuilder add(@NonNull Iterable args) { for (String arg : args) { add(arg); } diff --git a/core/src/main/java/hudson/util/AtomicFileWriter.java b/core/src/main/java/hudson/util/AtomicFileWriter.java index 27234651b2da..6d2f4fb3291e 100644 --- a/core/src/main/java/hudson/util/AtomicFileWriter.java +++ b/core/src/main/java/hudson/util/AtomicFileWriter.java @@ -25,8 +25,8 @@ import jenkins.util.SystemProperties; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -80,7 +80,7 @@ public AtomicFileWriter(File f) throws IOException { * @deprecated Use {@link #AtomicFileWriter(Path, Charset)} */ @Deprecated - public AtomicFileWriter(@Nonnull File f, @Nullable String encoding) throws IOException { + public AtomicFileWriter(@NonNull File f, @Nullable String encoding) throws IOException { this(toPath(f), encoding == null ? Charset.defaultCharset() : Charset.forName(encoding)); } @@ -92,7 +92,7 @@ public AtomicFileWriter(@Nonnull File f, @Nullable String encoding) throws IOExc * @return the path for that file * @see File#toPath() */ - private static Path toPath(@Nonnull File file) throws IOException { + private static Path toPath(@NonNull File file) throws IOException { try { return file.toPath(); } catch (InvalidPathException e) { @@ -104,7 +104,7 @@ private static Path toPath(@Nonnull File file) throws IOException { * @param destinationPath the destination path where to write the content when committed. * @param charset File charset to write. */ - public AtomicFileWriter(@Nonnull Path destinationPath, @Nonnull Charset charset) throws IOException { + public AtomicFileWriter(@NonNull Path destinationPath, @NonNull Charset charset) throws IOException { // See FileChannelWriter docs to understand why we do not cause a force() call on flush() from AtomicFileWriter. this(destinationPath, charset, false, true); } @@ -119,7 +119,7 @@ public AtomicFileWriter(@Nonnull Path destinationPath, @Nonnull Charset charset) * @deprecated use {@link AtomicFileWriter#AtomicFileWriter(Path, Charset)} */ @Deprecated - public AtomicFileWriter(@Nonnull Path destinationPath, @Nonnull Charset charset, boolean integrityOnFlush, boolean integrityOnClose) throws IOException { + public AtomicFileWriter(@NonNull Path destinationPath, @NonNull Charset charset, boolean integrityOnFlush, boolean integrityOnClose) throws IOException { if (charset == null) { // be extra-defensive if people don't care throw new IllegalArgumentException("charset is null"); } diff --git a/core/src/main/java/hudson/util/BootFailure.java b/core/src/main/java/hudson/util/BootFailure.java index 5649d79d6a2e..ae122e8c424c 100644 --- a/core/src/main/java/hudson/util/BootFailure.java +++ b/core/src/main/java/hudson/util/BootFailure.java @@ -4,7 +4,7 @@ import jenkins.util.groovy.GroovyHookScript; import org.kohsuke.stapler.WebApp; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.ServletContext; import java.io.BufferedReader; import java.io.File; diff --git a/core/src/main/java/hudson/util/DescriptorList.java b/core/src/main/java/hudson/util/DescriptorList.java index 2ade0531ca04..847329789864 100644 --- a/core/src/main/java/hudson/util/DescriptorList.java +++ b/core/src/main/java/hudson/util/DescriptorList.java @@ -37,7 +37,7 @@ import java.util.Iterator; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * List of {@link Descriptor}s. diff --git a/core/src/main/java/hudson/util/FormFillFailure.java b/core/src/main/java/hudson/util/FormFillFailure.java index 16b8e6435a2f..dd1d62e6f74b 100644 --- a/core/src/main/java/hudson/util/FormFillFailure.java +++ b/core/src/main/java/hudson/util/FormFillFailure.java @@ -27,7 +27,7 @@ import hudson.Util; import java.io.IOException; import java.util.Locale; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import jenkins.model.Jenkins; @@ -52,11 +52,11 @@ public abstract class FormFillFailure extends IOException implements HttpRespons * * @param message Human readable message to be sent. */ - public static FormFillFailure error(@Nonnull String message) { + public static FormFillFailure error(@NonNull String message) { return errorWithMarkup(Util.escape(message)); } - public static FormFillFailure warning(@Nonnull String message) { + public static FormFillFailure warning(@NonNull String message) { return warningWithMarkup(Util.escape(message)); } @@ -128,7 +128,7 @@ public static FormFillFailure warningWithMarkup(String message) { return _errorWithMarkup(message, FormValidation.Kind.WARNING); } - private static FormFillFailure _errorWithMarkup(@Nonnull final String message, final FormValidation.Kind kind) { + private static FormFillFailure _errorWithMarkup(@NonNull final String message, final FormValidation.Kind kind) { return new FormFillFailure(kind, message) { public String renderHtml() { StaplerRequest req = Stapler.getCurrentRequest(); diff --git a/core/src/main/java/hudson/util/FormValidation.java b/core/src/main/java/hudson/util/FormValidation.java index 94a0c4b2ac76..d3a88a5b9444 100644 --- a/core/src/main/java/hudson/util/FormValidation.java +++ b/core/src/main/java/hudson/util/FormValidation.java @@ -43,7 +43,7 @@ import org.kohsuke.stapler.Stapler; import org.springframework.util.StringUtils; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import java.io.File; @@ -219,7 +219,7 @@ public static FormValidation warning(Throwable e, String format, Object... args) * @return Validation of the least successful kind aggregating all child messages. * @since 1.590 */ - public static @Nonnull FormValidation aggregate(@Nonnull Collection validations) { + public static @NonNull FormValidation aggregate(@NonNull Collection validations) { if (validations == null || validations.isEmpty()) return FormValidation.ok(); if (validations.size() == 1) return validations.iterator().next(); diff --git a/core/src/main/java/hudson/util/Graph.java b/core/src/main/java/hudson/util/Graph.java index bef25b2d9e06..de98dd99a88a 100644 --- a/core/src/main/java/hudson/util/Graph.java +++ b/core/src/main/java/hudson/util/Graph.java @@ -36,8 +36,8 @@ import java.util.Calendar; import java.awt.image.BufferedImage; import java.awt.*; -import javax.annotation.Nonnull; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * A JFreeChart-generated graph that's bound to UI. @@ -98,7 +98,7 @@ private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) { return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info); } - @Nonnull private static Color stringToColor(@CheckForNull String s) { + @NonNull private static Color stringToColor(@CheckForNull String s) { if (s != null) { try { return Color.decode("0x" + s); diff --git a/core/src/main/java/hudson/util/HttpResponses.java b/core/src/main/java/hudson/util/HttpResponses.java index 78de2ecfb3e8..417b8fa1de18 100644 --- a/core/src/main/java/hudson/util/HttpResponses.java +++ b/core/src/main/java/hudson/util/HttpResponses.java @@ -29,7 +29,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import java.io.File; import java.io.IOException; @@ -64,7 +64,7 @@ public static HttpResponse okJSON() { * * @since 2.0 */ - public static HttpResponse okJSON(@Nonnull JSONObject data) { + public static HttpResponse okJSON(@NonNull JSONObject data) { return new JSONObjectResponse(data); } @@ -74,7 +74,7 @@ public static HttpResponse okJSON(@Nonnull JSONObject data) { * * @since 2.0 */ - public static HttpResponse okJSON(@Nonnull JSONArray data) { + public static HttpResponse okJSON(@NonNull JSONArray data) { return new JSONObjectResponse(data); } @@ -84,7 +84,7 @@ public static HttpResponse okJSON(@Nonnull JSONArray data) { * * @since 2.0 */ - public static HttpResponse okJSON(@Nonnull Map data) { + public static HttpResponse okJSON(@NonNull Map data) { return new JSONObjectResponse(data); } @@ -95,7 +95,7 @@ public static HttpResponse okJSON(@Nonnull Map data) { * * @since 2.0 */ - public static HttpResponse errorJSON(@Nonnull String message) { + public static HttpResponse errorJSON(@NonNull String message) { return new JSONObjectResponse().error(message); } @@ -107,7 +107,7 @@ public static HttpResponse errorJSON(@Nonnull String message) { * * @since 2.119 */ - public static HttpResponse errorJSON(@Nonnull String message, @Nonnull Map data) { + public static HttpResponse errorJSON(@NonNull String message, @NonNull Map data) { return new JSONObjectResponse(data).error(message); } @@ -119,7 +119,7 @@ public static HttpResponse errorJSON(@Nonnull String message, @Nonnull Map * * @since 2.115 */ - public static HttpResponse errorJSON(@Nonnull String message, @Nonnull JSONObject data) { + public static HttpResponse errorJSON(@NonNull String message, @NonNull JSONObject data) { return new JSONObjectResponse(data).error(message); } @@ -131,7 +131,7 @@ public static HttpResponse errorJSON(@Nonnull String message, @Nonnull JSONObjec * * @since 2.115 */ - public static HttpResponse errorJSON(@Nonnull String message, @Nonnull JSONArray data) { + public static HttpResponse errorJSON(@NonNull String message, @NonNull JSONArray data) { return new JSONObjectResponse(data).error(message); } @@ -156,7 +156,7 @@ static class JSONObjectResponse implements HttpResponse { * Create a response containing the supplied "data". * @param data The data. */ - JSONObjectResponse(@Nonnull JSONObject data) { + JSONObjectResponse(@NonNull JSONObject data) { this(); this.jsonObject.put("data", data); } @@ -165,7 +165,7 @@ static class JSONObjectResponse implements HttpResponse { * Create a response containing the supplied "data". * @param data The data. */ - JSONObjectResponse(@Nonnull JSONArray data) { + JSONObjectResponse(@NonNull JSONArray data) { this(); this.jsonObject.put("data", data); } @@ -174,7 +174,7 @@ static class JSONObjectResponse implements HttpResponse { * Create a response containing the supplied "data". * @param data The data. */ - JSONObjectResponse(@Nonnull Map data) { + JSONObjectResponse(@NonNull Map data) { this(); this.jsonObject.put("data", JSONObject.fromObject(data)); } @@ -184,7 +184,7 @@ static class JSONObjectResponse implements HttpResponse { * @param message The error "message" set on the response. * @return {@link this} object. */ - @Nonnull JSONObjectResponse error(@Nonnull String message) { + @NonNull JSONObjectResponse error(@NonNull String message) { status("error"); this.jsonObject.put("message", message); return this; @@ -194,11 +194,11 @@ static class JSONObjectResponse implements HttpResponse { * Get the JSON response object. * @return The JSON response object. */ - @Nonnull JSONObject getJsonObject() { + @NonNull JSONObject getJsonObject() { return jsonObject; } - private @Nonnull JSONObjectResponse status(@Nonnull String status) { + private @NonNull JSONObjectResponse status(@NonNull String status) { this.jsonObject.put("status", status); return this; } diff --git a/core/src/main/java/hudson/util/Iterators.java b/core/src/main/java/hudson/util/Iterators.java index 25b45f0c8510..f2a15723301e 100644 --- a/core/src/main/java/hudson/util/Iterators.java +++ b/core/src/main/java/hudson/util/Iterators.java @@ -35,7 +35,7 @@ import java.util.AbstractList; import java.util.Set; import java.util.HashSet; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -413,7 +413,7 @@ public interface CountingPredicate { * @param count a nonnegative count */ @Restricted(NoExternalUse.class) - public static void skip(@Nonnull Iterator iterator, int count) { + public static void skip(@NonNull Iterator iterator, int count) { if (count < 0) { throw new IllegalArgumentException(); } diff --git a/core/src/main/java/hudson/util/KeyedDataStorage.java b/core/src/main/java/hudson/util/KeyedDataStorage.java index 93f15b6a09ae..262514dadf2c 100644 --- a/core/src/main/java/hudson/util/KeyedDataStorage.java +++ b/core/src/main/java/hudson/util/KeyedDataStorage.java @@ -31,8 +31,8 @@ import java.text.MessageFormat; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Convenient base class for implementing data storage. @@ -107,7 +107,7 @@ public synchronized void set(@CheckForNull T value) { * Additional parameters needed to create a new data object. Can be null. * @throws IOException Loading error */ - public @Nonnull T getOrCreate(String key, P createParams) throws IOException { + public @NonNull T getOrCreate(String key, P createParams) throws IOException { return get(key,true,createParams); } @@ -126,7 +126,7 @@ public synchronized void set(@CheckForNull T value) { * @return Item with the specified {@code key} * @throws IOException Loading error */ - protected @CheckForNull T get(@Nonnull String key, boolean createIfNotExist, P createParams) throws IOException { + protected @CheckForNull T get(@NonNull String key, boolean createIfNotExist, P createParams) throws IOException { while(true) { totalQuery.incrementAndGet(); Object value = core.get(key); @@ -219,7 +219,7 @@ public synchronized void set(@CheckForNull T value) { * {@link IOException} (or any other exception) and that will be * propagated to the caller. */ - protected abstract @Nonnull T create(@Nonnull String key, @Nonnull P createParams) throws IOException; + protected abstract @NonNull T create(@NonNull String key, @NonNull P createParams) throws IOException; public void resetPerformanceStats() { totalQuery.set(0); diff --git a/core/src/main/java/hudson/util/MultipartFormDataParser.java b/core/src/main/java/hudson/util/MultipartFormDataParser.java index 39cac1c987e9..14b151772555 100644 --- a/core/src/main/java/hudson/util/MultipartFormDataParser.java +++ b/core/src/main/java/hudson/util/MultipartFormDataParser.java @@ -29,7 +29,7 @@ import org.apache.commons.fileupload.FileUploadException; import org.apache.commons.lang.ArrayUtils; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.http.HttpServletRequest; import javax.servlet.ServletException; import java.util.Map; diff --git a/core/src/main/java/hudson/util/PluginServletFilter.java b/core/src/main/java/hudson/util/PluginServletFilter.java index 78e9eb73a971..292902478282 100644 --- a/core/src/main/java/hudson/util/PluginServletFilter.java +++ b/core/src/main/java/hudson/util/PluginServletFilter.java @@ -28,7 +28,7 @@ import java.util.ArrayList; import jenkins.model.Jenkins; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; diff --git a/core/src/main/java/hudson/util/ProcessKillingVeto.java b/core/src/main/java/hudson/util/ProcessKillingVeto.java index b8b874e42a55..1814afa32b75 100644 --- a/core/src/main/java/hudson/util/ProcessKillingVeto.java +++ b/core/src/main/java/hudson/util/ProcessKillingVeto.java @@ -30,8 +30,8 @@ import java.util.Collections; import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.util.JenkinsJVM; @@ -58,14 +58,14 @@ public static class VetoCause { /** * @param message A string describing the reason for the veto */ - public VetoCause(@Nonnull String message) { + public VetoCause(@NonNull String message) { this.message = message; } /** * @return A string describing the reason for the veto. */ - public @Nonnull String getMessage() { + public @NonNull String getMessage() { return message; } } @@ -99,5 +99,5 @@ private static List _all() { * null else. */ @CheckForNull - public abstract VetoCause vetoProcessKilling(@Nonnull IOSProcess p); + public abstract VetoCause vetoProcessKilling(@NonNull IOSProcess p); } diff --git a/core/src/main/java/hudson/util/ProcessTree.java b/core/src/main/java/hudson/util/ProcessTree.java index 4a0db317657a..b12a967a8060 100644 --- a/core/src/main/java/hudson/util/ProcessTree.java +++ b/core/src/main/java/hudson/util/ProcessTree.java @@ -73,13 +73,13 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import static com.sun.jna.Pointer.NULL; import jenkins.util.SystemProperties; import static hudson.util.jna.GNUCLibrary.LIBC; import static java.util.logging.Level.FINER; import static java.util.logging.Level.FINEST; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Represents a snapshot of the process tree of the current system. @@ -132,7 +132,7 @@ public final OSProcess get(int pid) { /** * Lists all the processes in the system. */ - @Nonnull + @NonNull public final Iterator iterator() { return processes.values().iterator(); } @@ -143,7 +143,7 @@ public final Iterator iterator() { * this process has already finished.) */ @CheckForNull - public abstract OSProcess get(@Nonnull Process proc); + public abstract OSProcess get(@NonNull Process proc); /** * Kills all the processes that have matching environment variables. @@ -157,7 +157,7 @@ public final Iterator iterator() { * them all. This is suitable for locating daemon processes * that cannot be tracked by the regular ancestor/descendant relationship. */ - public abstract void killAll(@Nonnull Map modelEnvVars) throws InterruptedException; + public abstract void killAll(@NonNull Map modelEnvVars) throws InterruptedException; /** * The time to wait between sending Ctrl+C and killing the process. (JENKINS-17116) @@ -189,7 +189,7 @@ public void killAll(@CheckForNull Process proc, @CheckForNull Map getKillers() throws InterruptedException { if (killers==null) try { @@ -243,7 +243,7 @@ public final int getPid() { /** * Immediate child processes. */ - @Nonnull + @NonNull public final List getChildren() { List r = new ArrayList<>(); for (OSProcess p : ProcessTree.this) @@ -313,7 +313,7 @@ void killByKiller() throws InterruptedException { * On Windows, where the OS models command-line arguments as a single string, this method * computes the approximated tokenization. */ - @Nonnull + @NonNull public abstract List getArguments(); /** @@ -323,7 +323,7 @@ void killByKiller() throws InterruptedException { * empty map if failed (for example because the process is already dead, * or the permission was denied.) */ - @Nonnull + @NonNull public abstract EnvVars getEnvironmentVariables(); /** @@ -480,7 +480,7 @@ public Boolean call() throws IOException { * Empty process list as a default value if the platform doesn't support it. */ /*package*/ static final ProcessTree DEFAULT = new Local() { - public OSProcess get(@Nonnull final Process proc) { + public OSProcess get(@NonNull final Process proc) { return new OSProcess(-1) { @CheckForNull public OSProcess getParent() { @@ -499,19 +499,19 @@ public void kill() throws InterruptedException { killByKiller(); } - @Nonnull + @NonNull public List getArguments() { return Collections.emptyList(); } - @Nonnull + @NonNull public EnvVars getEnvironmentVariables() { return new EnvVars(); } }; } - public void killAll(@Nonnull Map modelEnvVars) { + public void killAll(@NonNull Map modelEnvVars) { // no-op } }; @@ -586,7 +586,7 @@ private void killSoftly() throws InterruptedException { } while (System.nanoTime() < deadline); } - @Nonnull + @NonNull @Override public synchronized List getArguments() { if(args==null) { @@ -595,7 +595,7 @@ public synchronized List getArguments() { return args; } - @Nonnull + @NonNull @Override public synchronized EnvVars getEnvironmentVariables() { try { @@ -665,12 +665,12 @@ private static final class Windows extends Local { @CheckForNull @Override - public OSProcess get(@Nonnull Process proc) { + public OSProcess get(@NonNull Process proc) { return get(new WinProcess(proc).getPid()); } @Override - public void killAll(@Nonnull Map modelEnvVars) throws InterruptedException { + public void killAll(@NonNull Map modelEnvVars) throws InterruptedException { for( OSProcess p : this) { if(p.getPid()<10) continue; // ignore system processes like "idle process" @@ -701,7 +701,7 @@ public void killAll(@Nonnull Map modelEnvVars) throws Interrupte WinProcess.enableDebugPrivilege(); } - private static boolean hasMatchingEnvVars(@Nonnull OSProcess p, @Nonnull Map modelEnvVars) + private static boolean hasMatchingEnvVars(@NonNull OSProcess p, @NonNull Map modelEnvVars) throws WindowsOSProcessException { if (p instanceof WindowsOSProcess) { return ((WindowsOSProcess)p).hasMatchingEnvVars2(modelEnvVars); @@ -724,11 +724,11 @@ public Unix(boolean vetoersExist) { @CheckForNull @Override - public OSProcess get(@Nonnull Process proc) { + public OSProcess get(@NonNull Process proc) { return get(UnixReflection.pid(proc)); } - public void killAll(@Nonnull Map modelEnvVars) throws InterruptedException { + public void killAll(@NonNull Map modelEnvVars) throws InterruptedException { for (OSProcess p : this) if(p.hasMatchingEnvVars(modelEnvVars)) p.killRecursively(); @@ -850,7 +850,7 @@ private void killRecursively(long deadline) throws InterruptedException { * empty list if failed (for example because the process is already dead, * or the permission was denied.) */ - @Nonnull + @NonNull public abstract List getArguments(); } @@ -919,7 +919,7 @@ public static void destroy(int pid) throws IllegalAccessException, } //TODO: We ideally need to update ProcessTree APIs to Support Long (JENKINS-53799). - public static int pid(@Nonnull Process proc) { + public static int pid(@NonNull Process proc) { try { if (JAVA8_PID_FIELD != null) { return JAVA8_PID_FIELD.getInt(proc); @@ -975,7 +975,7 @@ public OSProcess getParent() { return get(ppid); } - @Nonnull + @NonNull public synchronized List getArguments() { if(arguments!=null) return arguments; @@ -998,7 +998,7 @@ public synchronized List getArguments() { return arguments; } - @Nonnull + @NonNull public synchronized EnvVars getEnvironmentVariables() { if(envVars !=null) return envVars; @@ -1197,7 +1197,7 @@ public OSProcess getParent() { return get(ppid); } - @Nonnull + @NonNull public synchronized List getArguments() { if (arguments != null) return arguments; @@ -1244,7 +1244,7 @@ public synchronized List getArguments() { return arguments; } - @Nonnull + @NonNull public synchronized EnvVars getEnvironmentVariables() { if(envVars != null) return envVars; @@ -1484,7 +1484,7 @@ public OSProcess getParent() { return get(ppid); } - @Nonnull + @NonNull public synchronized List getArguments() { if(arguments!=null) return arguments; @@ -1520,7 +1520,7 @@ public synchronized List getArguments() { return arguments; } - @Nonnull + @NonNull public synchronized EnvVars getEnvironmentVariables() { if(envVars !=null) return envVars; @@ -1681,7 +1681,7 @@ public OSProcess getParent() { return get(ppid); } - @Nonnull + @NonNull public synchronized EnvVars getEnvironmentVariables() { if(envVars !=null) return envVars; @@ -1689,7 +1689,7 @@ public synchronized EnvVars getEnvironmentVariables() { return envVars; } - @Nonnull + @NonNull public List getArguments() { if(arguments !=null) return arguments; @@ -1872,12 +1872,12 @@ public Remote(ProcessTree proxy, Channel ch, boolean vetoersExist) { @CheckForNull @Override - public OSProcess get(@Nonnull Process proc) { + public OSProcess get(@NonNull Process proc) { return null; } @Override - public void killAll(@Nonnull Map modelEnvVars) throws InterruptedException { + public void killAll(@NonNull Map modelEnvVars) throws InterruptedException { proxy.killAll(modelEnvVars); } @@ -1910,12 +1910,12 @@ public void killRecursively() throws InterruptedException { proxy.killRecursively(); } - @Nonnull + @NonNull public List getArguments() { return proxy.getArguments(); } - @Nonnull + @NonNull public EnvVars getEnvironmentVariables() { return proxy.getEnvironmentVariables(); } diff --git a/core/src/main/java/hudson/util/ProcessTreeRemoting.java b/core/src/main/java/hudson/util/ProcessTreeRemoting.java index d031c9dffd76..b495e81ca100 100644 --- a/core/src/main/java/hudson/util/ProcessTreeRemoting.java +++ b/core/src/main/java/hudson/util/ProcessTreeRemoting.java @@ -3,8 +3,8 @@ import hudson.EnvVars; import hudson.util.ProcessTree.ProcessCallable; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.lang.reflect.Proxy; import java.util.List; @@ -19,7 +19,7 @@ */ public class ProcessTreeRemoting { public interface IProcessTree { - void killAll(@Nonnull Map modelEnvVars) throws InterruptedException; + void killAll(@NonNull Map modelEnvVars) throws InterruptedException; } public interface IOSProcess { @@ -28,9 +28,9 @@ public interface IOSProcess { IOSProcess getParent(); void kill() throws InterruptedException; void killRecursively() throws InterruptedException; - @Nonnull + @NonNull List getArguments(); - @Nonnull + @NonNull EnvVars getEnvironmentVariables(); T act(ProcessCallable callable) throws IOException, InterruptedException; } diff --git a/core/src/main/java/hudson/util/ReflectionUtils.java b/core/src/main/java/hudson/util/ReflectionUtils.java index faa6afb99a32..7ff60e84b001 100644 --- a/core/src/main/java/hudson/util/ReflectionUtils.java +++ b/core/src/main/java/hudson/util/ReflectionUtils.java @@ -37,7 +37,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Utility code for reflection. diff --git a/core/src/main/java/hudson/util/RemotingDiagnostics.java b/core/src/main/java/hudson/util/RemotingDiagnostics.java index bac1a86e2817..57e6ec210f78 100644 --- a/core/src/main/java/hudson/util/RemotingDiagnostics.java +++ b/core/src/main/java/hudson/util/RemotingDiagnostics.java @@ -41,7 +41,7 @@ import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.WebMethod; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.management.JMException; import javax.management.MBeanServer; import javax.management.ObjectName; @@ -107,7 +107,7 @@ public Map call() { /** * Executes Groovy script remotely. */ - public static String executeGroovy(String script, @Nonnull VirtualChannel channel) throws IOException, InterruptedException { + public static String executeGroovy(String script, @NonNull VirtualChannel channel) throws IOException, InterruptedException { return channel.call(new Script(script)); } diff --git a/core/src/main/java/hudson/util/Retrier.java b/core/src/main/java/hudson/util/Retrier.java index 5585df2c4c64..b4dcb3ef136c 100644 --- a/core/src/main/java/hudson/util/Retrier.java +++ b/core/src/main/java/hudson/util/Retrier.java @@ -3,8 +3,8 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.Arrays; import java.util.concurrent.Callable; import java.util.function.BiFunction; @@ -122,7 +122,7 @@ public static class Builder { * @param attempts number of attempts * @return this builder */ - public @Nonnull Builder withAttempts(int attempts) { + public @NonNull Builder withAttempts(int attempts) { this.attempts = attempts; return this; } @@ -132,7 +132,7 @@ public static class Builder { * @param millis milliseconds to wait * @return this builder */ - public @Nonnull Builder withDelay(long millis) { + public @NonNull Builder withDelay(long millis) { this.delay = millis; return this; } @@ -144,7 +144,7 @@ public static class Builder { * @param exceptions exceptions that indicate that the action was failed. * @return this builder */ - public @Nonnull Builder withDuringActionExceptions(@CheckForNull Class[] exceptions) { + public @NonNull Builder withDuringActionExceptions(@CheckForNull Class[] exceptions) { this.duringActionExceptions = exceptions != null ? Arrays.copyOf(exceptions, exceptions.length) : null; return this; } @@ -155,7 +155,7 @@ public static class Builder { * @param exceptionListener the listener to call to * @return this builder */ - public @Nonnull Builder withDuringActionExceptionListener(@Nonnull BiFunction exceptionListener) { + public @NonNull Builder withDuringActionExceptionListener(@NonNull BiFunction exceptionListener) { this.duringActionExceptionListener = exceptionListener; return this; } @@ -167,7 +167,7 @@ public static class Builder { * @param action name of the action to perform, for messages purposes. */ - public Builder(@Nonnull Callable callable, @Nonnull BiPredicate checkResult, @Nonnull String action) { + public Builder(@NonNull Callable callable, @NonNull BiPredicate checkResult, @NonNull String action) { this.callable = callable; this.action = action; this.checkResult = checkResult; @@ -177,7 +177,7 @@ public Builder(@Nonnull Callable callable, @Nonnull BiPredicate c * Create a Retrier object with the specification set in this builder. * @return the retrier */ - public @Nonnull Retrier build() { + public @NonNull Retrier build() { return new Retrier<>(this); } } diff --git a/core/src/main/java/hudson/util/RobustReflectionConverter.java b/core/src/main/java/hudson/util/RobustReflectionConverter.java index a2907d2517aa..976d1755f757 100644 --- a/core/src/main/java/hudson/util/RobustReflectionConverter.java +++ b/core/src/main/java/hudson/util/RobustReflectionConverter.java @@ -54,8 +54,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock; import static java.util.logging.Level.FINE; import java.util.logging.Logger; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.GuardedBy; +import edu.umd.cs.findbugs.annotations.NonNull; +import net.jcip.annotations.GuardedBy; import jenkins.util.xstream.CriticalXStreamException; /** @@ -75,7 +75,7 @@ public class RobustReflectionConverter implements Converter { protected final Mapper mapper; protected transient SerializationMethodInvoker serializationMethodInvoker; private transient ReflectionProvider pureJavaReflectionProvider; - private final @Nonnull XStream2.ClassOwnership classOwnership; + private final @NonNull XStream2.ClassOwnership classOwnership; /** There are typically few critical fields around, but we end up looking up in this map a lot. in addition, this map is really only written to during static initialization, so we should use reader writer lock to avoid locking as much as possible. In addition, to avoid looking up diff --git a/core/src/main/java/hudson/util/Secret.java b/core/src/main/java/hudson/util/Secret.java index 3f7eacc3e2a1..bbda0d6d6a66 100644 --- a/core/src/main/java/hudson/util/Secret.java +++ b/core/src/main/java/hudson/util/Secret.java @@ -43,8 +43,8 @@ import java.util.Base64; import java.util.logging.Logger; import java.util.regex.Pattern; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -70,7 +70,7 @@ public final class Secret implements Serializable { /** * Unencrypted secret text. */ - @Nonnull + @NonNull private final String value; private byte[] iv; @@ -104,7 +104,7 @@ public String toString() { * Before using this method, ask yourself if you'd be better off using {@link Secret#toString(Secret)} * to avoid NPE. */ - @Nonnull + @NonNull public String getPlainText() { return value; } @@ -245,7 +245,7 @@ public static Cipher getCipher(String algorithm) throws GeneralSecurityException *

* Useful for recovering a value from a form field. */ - @Nonnull + @NonNull public static Secret fromString(@CheckForNull String data) { data = Util.fixNull(data); Secret s = decrypt(data); @@ -258,7 +258,7 @@ public static Secret fromString(@CheckForNull String data) { * To be consistent with {@link #fromString(String)}, this method doesn't distinguish * empty password and null password. */ - @Nonnull + @NonNull public static String toString(@CheckForNull Secret s) { return s==null ? "" : s.value; } diff --git a/core/src/main/java/hudson/util/SequentialExecutionQueue.java b/core/src/main/java/hudson/util/SequentialExecutionQueue.java index d2ba8209c0c2..d6d035eef1fd 100644 --- a/core/src/main/java/hudson/util/SequentialExecutionQueue.java +++ b/core/src/main/java/hudson/util/SequentialExecutionQueue.java @@ -1,6 +1,6 @@ package hudson.util; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -59,7 +59,7 @@ public synchronized void setExecutors(ExecutorService svc) { } - public synchronized void execute(@Nonnull Runnable item) { + public synchronized void execute(@NonNull Runnable item) { QueueEntry e = entries.get(item); if(e==null) { e = new QueueEntry(item); diff --git a/core/src/main/java/hudson/util/StreamTaskListener.java b/core/src/main/java/hudson/util/StreamTaskListener.java index 931a0b99bba8..af1d84cca34e 100644 --- a/core/src/main/java/hudson/util/StreamTaskListener.java +++ b/core/src/main/java/hudson/util/StreamTaskListener.java @@ -45,8 +45,8 @@ import jenkins.util.SystemProperties; import org.kohsuke.stapler.framework.io.WriterOutputStream; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; // TODO: AbstractTaskListener is empty now, but there are dependencies on that e.g. Ruby Runtime - JENKINS-48116) // The change needs API deprecation policy or external usages cleanup. @@ -60,7 +60,7 @@ * @author Kohsuke Kawaguchi */ public class StreamTaskListener extends AbstractTaskListener implements TaskListener, Closeable { - @Nonnull + @NonNull private PrintStream out; @CheckForNull private Charset charset; @@ -72,15 +72,15 @@ public class StreamTaskListener extends AbstractTaskListener implements TaskList * or use {@link #fromStdout()} or {@link #fromStderr()}. */ @Deprecated - public StreamTaskListener(@Nonnull PrintStream out) { + public StreamTaskListener(@NonNull PrintStream out) { this(out,null); } - public StreamTaskListener(@Nonnull OutputStream out) { + public StreamTaskListener(@NonNull OutputStream out) { this(out,null); } - public StreamTaskListener(@Nonnull OutputStream out, @CheckForNull Charset charset) { + public StreamTaskListener(@NonNull OutputStream out, @CheckForNull Charset charset) { try { if (charset == null) this.out = (out instanceof PrintStream) ? (PrintStream)out : new PrintStream(out, false); @@ -93,18 +93,18 @@ public StreamTaskListener(@Nonnull OutputStream out, @CheckForNull Charset chars } } - public StreamTaskListener(@Nonnull File out) throws IOException { + public StreamTaskListener(@NonNull File out) throws IOException { this(out,null); } - public StreamTaskListener(@Nonnull File out, @CheckForNull Charset charset) throws IOException { + public StreamTaskListener(@NonNull File out, @CheckForNull Charset charset) throws IOException { // don't do buffering so that what's written to the listener // gets reflected to the file immediately, which can then be // served to the browser immediately this(Files.newOutputStream(asPath(out)), charset); } - private static Path asPath(@Nonnull File out) throws IOException { + private static Path asPath(@NonNull File out) throws IOException { try { return out.toPath(); } catch (InvalidPathException e) { @@ -121,7 +121,7 @@ private static Path asPath(@Nonnull File out) throws IOException { * @throws IOException if the file could not be opened. * @since 1.651 */ - public StreamTaskListener(@Nonnull File out, boolean append, @CheckForNull Charset charset) throws IOException { + public StreamTaskListener(@NonNull File out, boolean append, @CheckForNull Charset charset) throws IOException { // don't do buffering so that what's written to the listener // gets reflected to the file immediately, which can then be // served to the browser immediately @@ -133,7 +133,7 @@ public StreamTaskListener(@Nonnull File out, boolean append, @CheckForNull Chars ); } - public StreamTaskListener(@Nonnull Writer w) throws IOException { + public StreamTaskListener(@NonNull Writer w) throws IOException { this(new WriterOutputStream(w)); } diff --git a/core/src/main/java/hudson/util/TextFile.java b/core/src/main/java/hudson/util/TextFile.java index ee06f713a5dc..0830898c21f4 100644 --- a/core/src/main/java/hudson/util/TextFile.java +++ b/core/src/main/java/hudson/util/TextFile.java @@ -29,7 +29,7 @@ import jenkins.util.io.LinesStream; import java.nio.file.Files; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -50,9 +50,9 @@ */ public class TextFile { - public final @Nonnull File file; + public final @NonNull File file; - public TextFile(@Nonnull File file) { + public TextFile(@NonNull File file) { this.file = file; } @@ -86,7 +86,7 @@ public String read() throws IOException { * if the collection is not fully iterated. Use {@link #linesStream()} instead. */ @Deprecated - public @Nonnull Iterable lines() { + public @NonNull Iterable lines() { try { return linesStream(); } catch (IOException ex) { @@ -104,7 +104,7 @@ public String read() throws IOException { * @since 2.111 */ @CreatesObligation - public @Nonnull LinesStream linesStream() throws IOException { + public @NonNull LinesStream linesStream() throws IOException { return new LinesStream(Util.fileToPath(file)); } @@ -126,7 +126,7 @@ public void write(String text) throws IOException { /** * Reads the first N characters or until we hit EOF. */ - public @Nonnull String head(int numChars) throws IOException { + public @NonNull String head(int numChars) throws IOException { char[] buf = new char[numChars]; int read = 0; try (Reader r = new FileReader(file)) { @@ -171,7 +171,7 @@ public void write(String text) throws IOException { *

* So all in all, this algorithm should work decently, and it works quite efficiently on a large text. */ - public @Nonnull String fastTail(int numChars, Charset cs) throws IOException { + public @NonNull String fastTail(int numChars, Charset cs) throws IOException { try (RandomAccessFile raf = new RandomAccessFile(file, "r")) { long len = raf.length(); @@ -192,7 +192,7 @@ public void write(String text) throws IOException { /** * Uses the platform default encoding. */ - public @Nonnull String fastTail(int numChars) throws IOException { + public @NonNull String fastTail(int numChars) throws IOException { return fastTail(numChars,Charset.defaultCharset()); } diff --git a/core/src/main/java/hudson/util/XStream2.java b/core/src/main/java/hudson/util/XStream2.java index fb3e4a84310d..c86e82308ec0 100644 --- a/core/src/main/java/hudson/util/XStream2.java +++ b/core/src/main/java/hudson/util/XStream2.java @@ -78,8 +78,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.regex.Pattern; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * {@link XStream} enhanced for additional Java5 support and improved robustness. @@ -141,7 +141,7 @@ public Object unmarshal(HierarchicalStreamReader reader, Object root, DataHolder * Even for primitive-valued fields, it is useful to guarantee * that unmarshaling will produce the same result as creating a new instance. *

Do not use in cases where the root objects defines fields (typically {@code final}) - * which it expects to be {@link Nonnull} unless you are prepared to restore default values for those fields. + * which it expects to be {@link NonNull} unless you are prepared to restore default values for those fields. * @param nullOut whether to perform this special behavior; * false to use the stock XStream behavior of leaving unmentioned {@code root} fields untouched * @see XmlFile#unmarshalNullingOut diff --git a/core/src/main/java/hudson/views/MyViewsTabBar.java b/core/src/main/java/hudson/views/MyViewsTabBar.java index 90ab81cf8ea4..7a7c4153bbbe 100644 --- a/core/src/main/java/hudson/views/MyViewsTabBar.java +++ b/core/src/main/java/hudson/views/MyViewsTabBar.java @@ -32,7 +32,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.GlobalConfiguration; import jenkins.model.Jenkins; import hudson.model.MyViewsProperty; @@ -77,10 +77,10 @@ public MyViewsTabBarDescriptor getDescriptor() { * @return the sorted views * @since 2.37 */ - @Nonnull + @NonNull @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // invoked from stapler view - public List sort(@Nonnull List views) { + public List sort(@NonNull List views) { List result = new ArrayList<>(views); result.sort(new Comparator() { @Override diff --git a/core/src/main/java/hudson/views/ViewsTabBar.java b/core/src/main/java/hudson/views/ViewsTabBar.java index 69a3ba6bb073..93aa30845640 100644 --- a/core/src/main/java/hudson/views/ViewsTabBar.java +++ b/core/src/main/java/hudson/views/ViewsTabBar.java @@ -32,7 +32,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.GlobalConfiguration; import jenkins.model.Jenkins; import hudson.model.ListView; @@ -78,10 +78,10 @@ public ViewsTabBarDescriptor getDescriptor() { * @return the sorted views * @since 2.37 */ - @Nonnull + @NonNull @Restricted(NoExternalUse.class) @SuppressWarnings("unused") // invoked from stapler view - public List sort(@Nonnull List views) { + public List sort(@NonNull List views) { List result = new ArrayList<>(views); result.sort(new Comparator() { @Override diff --git a/core/src/main/java/hudson/widgets/HistoryWidget.java b/core/src/main/java/hudson/widgets/HistoryWidget.java index 09fbaa250c85..596fa205ee8b 100644 --- a/core/src/main/java/hudson/widgets/HistoryWidget.java +++ b/core/src/main/java/hudson/widgets/HistoryWidget.java @@ -35,7 +35,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.ServletException; import java.io.IOException; import java.util.ArrayList; diff --git a/core/src/main/java/jenkins/AgentProtocol.java b/core/src/main/java/jenkins/AgentProtocol.java index 39a7f0f13a00..07f8e8df9a27 100644 --- a/core/src/main/java/jenkins/AgentProtocol.java +++ b/core/src/main/java/jenkins/AgentProtocol.java @@ -8,7 +8,7 @@ import java.io.IOException; import java.net.Socket; import java.util.Set; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.model.Jenkins; diff --git a/core/src/main/java/jenkins/ClassLoaderReflectionToolkit.java b/core/src/main/java/jenkins/ClassLoaderReflectionToolkit.java index 895148909fc3..052fc7bd8f23 100644 --- a/core/src/main/java/jenkins/ClassLoaderReflectionToolkit.java +++ b/core/src/main/java/jenkins/ClassLoaderReflectionToolkit.java @@ -5,8 +5,8 @@ import java.lang.reflect.Method; import java.net.URL; import java.util.Enumeration; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Reflective access to various {@link ClassLoader} methods which are otherwise {@code protected}. @@ -76,7 +76,7 @@ private static Object getClassLoadingLock(ClassLoader cl, String name) { * Calls {@link ClassLoader#findClass} while holding {@link ClassLoader#getClassLoadingLock}. * @since 1.553 */ - public static @Nonnull Class _findClass(ClassLoader cl, String name) throws ClassNotFoundException { + public static @NonNull Class _findClass(ClassLoader cl, String name) throws ClassNotFoundException { synchronized (getClassLoadingLock(cl, name)) { return (Class) invoke(FIND_CLASS, ClassNotFoundException.class, cl, name); } @@ -94,7 +94,7 @@ private static Object getClassLoadingLock(ClassLoader cl, String name) { * Calls {@link ClassLoader#findResources}. * @since 1.553 */ - public static @Nonnull Enumeration _findResources(ClassLoader cl, String name) throws IOException { + public static @NonNull Enumeration _findResources(ClassLoader cl, String name) throws IOException { return (Enumeration) invoke(FIND_RESOURCES, IOException.class, cl, name); } diff --git a/core/src/main/java/jenkins/FilePathFilter.java b/core/src/main/java/jenkins/FilePathFilter.java index 4d4eb4f2be2f..01681021f86f 100644 --- a/core/src/main/java/jenkins/FilePathFilter.java +++ b/core/src/main/java/jenkins/FilePathFilter.java @@ -5,7 +5,7 @@ import hudson.remoting.ChannelBuilder; import jenkins.security.ChannelConfigurator; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.io.File; /** diff --git a/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java b/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java index 951eb432fcc0..bd9ade9a0541 100644 --- a/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java +++ b/core/src/main/java/jenkins/MetaLocaleDrivenResourceProvider.java @@ -30,8 +30,8 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.LocaleDrivenResourceProvider; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.net.URL; /** @@ -45,7 +45,7 @@ public final class MetaLocaleDrivenResourceProvider extends LocaleDrivenResource @Override @CheckForNull - public URL lookup(@Nonnull String s) { + public URL lookup(@NonNull String s) { for (PluginLocaleDrivenResourceProvider provider : ExtensionList.lookup(PluginLocaleDrivenResourceProvider.class)) { try { URL url = provider.lookup(s); diff --git a/core/src/main/java/jenkins/PluginLocaleDrivenResourceProvider.java b/core/src/main/java/jenkins/PluginLocaleDrivenResourceProvider.java index 367d664f2f68..03897b67c7de 100644 --- a/core/src/main/java/jenkins/PluginLocaleDrivenResourceProvider.java +++ b/core/src/main/java/jenkins/PluginLocaleDrivenResourceProvider.java @@ -25,8 +25,8 @@ import hudson.ExtensionPoint; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.net.URL; /** @@ -44,5 +44,5 @@ public interface PluginLocaleDrivenResourceProvider extends ExtensionPoint { * @return URL to the localized resource, or {@code null} if inapplicable. */ @CheckForNull - URL lookup(@Nonnull String s); + URL lookup(@NonNull String s); } diff --git a/core/src/main/java/jenkins/SoloFilePathFilter.java b/core/src/main/java/jenkins/SoloFilePathFilter.java index aa0ebbefc859..33240292304c 100644 --- a/core/src/main/java/jenkins/SoloFilePathFilter.java +++ b/core/src/main/java/jenkins/SoloFilePathFilter.java @@ -2,7 +2,7 @@ import hudson.FilePath; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; import java.io.File; /** diff --git a/core/src/main/java/jenkins/install/InstallState.java b/core/src/main/java/jenkins/install/InstallState.java index 19e2e360e3cf..bbed401f3b4d 100644 --- a/core/src/main/java/jenkins/install/InstallState.java +++ b/core/src/main/java/jenkins/install/InstallState.java @@ -23,8 +23,8 @@ */ package jenkins.install; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.ExtensionList; @@ -232,7 +232,7 @@ public void initializeState() { */ private final String name; - public InstallState(@Nonnull String name, boolean isSetupComplete) { + public InstallState(@NonNull String name, boolean isSetupComplete) { this.name = name; this.isSetupComplete = isSetupComplete; } @@ -303,7 +303,7 @@ public String toString() { * @return */ @CheckForNull - public static InstallState valueOf(@Nonnull String name) { + public static InstallState valueOf(@NonNull String name) { for (InstallState state : all()) { if (name.equals(state.name)) { return state; diff --git a/core/src/main/java/jenkins/install/InstallUtil.java b/core/src/main/java/jenkins/install/InstallUtil.java index be9688e894c0..009f727b22a0 100644 --- a/core/src/main/java/jenkins/install/InstallUtil.java +++ b/core/src/main/java/jenkins/install/InstallUtil.java @@ -36,8 +36,8 @@ import java.util.Map; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.inject.Provider; import org.apache.commons.io.FileUtils; @@ -221,7 +221,7 @@ public static void saveLastExecVersion() { * @return The last saved Jenkins instance version. * @see #saveLastExecVersion() */ - public static @Nonnull String getLastExecVersion() { + public static @NonNull String getLastExecVersion() { File lastExecVersionFile = getLastExecVersionFile(); if (lastExecVersionFile.exists()) { try { @@ -265,7 +265,7 @@ public static void saveLastExecVersion() { * Save a specific version as the last execute version. * @param version The version to save. */ - static void saveLastExecVersion(@Nonnull String version) { + static void saveLastExecVersion(@NonNull String version) { File lastExecVersionFile = getLastExecVersionFile(); try { FileUtils.write(lastExecVersionFile, version, Charset.defaultCharset()); diff --git a/core/src/main/java/jenkins/install/SetupWizard.java b/core/src/main/java/jenkins/install/SetupWizard.java index f10fdbf6879b..aba77a48230b 100644 --- a/core/src/main/java/jenkins/install/SetupWizard.java +++ b/core/src/main/java/jenkins/install/SetupWizard.java @@ -12,7 +12,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; diff --git a/core/src/main/java/jenkins/management/AsynchronousAdministrativeMonitor.java b/core/src/main/java/jenkins/management/AsynchronousAdministrativeMonitor.java index a5e64b38f4f4..e7bc8c46a0f8 100644 --- a/core/src/main/java/jenkins/management/AsynchronousAdministrativeMonitor.java +++ b/core/src/main/java/jenkins/management/AsynchronousAdministrativeMonitor.java @@ -16,7 +16,7 @@ import java.nio.charset.Charset; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Convenient partial implementation of {@link AdministrativeMonitor} that involves a background "fixing" action @@ -120,7 +120,7 @@ public void run() { * Runs the monitor and encapsulates all errors within. * @since 1.590 */ - private void doRun(@Nonnull TaskListener listener) { + private void doRun(@NonNull TaskListener listener) { try { fix(listener); } catch (AbortException e) { diff --git a/core/src/main/java/jenkins/management/CliLink.java b/core/src/main/java/jenkins/management/CliLink.java index d8ea26682849..d2ee8717ca29 100644 --- a/core/src/main/java/jenkins/management/CliLink.java +++ b/core/src/main/java/jenkins/management/CliLink.java @@ -30,7 +30,7 @@ import jenkins.model.Jenkins; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -52,7 +52,7 @@ public String getDescription() { return Messages.CliLink_Description(); } - @Nonnull + @NonNull @Override public Permission getRequiredPermission() { return Jenkins.MANAGE; @@ -63,7 +63,7 @@ public String getUrlName() { return "cli"; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.TOOLS; diff --git a/core/src/main/java/jenkins/management/ConfigureLink.java b/core/src/main/java/jenkins/management/ConfigureLink.java index b10be80d55c6..234a5527f972 100644 --- a/core/src/main/java/jenkins/management/ConfigureLink.java +++ b/core/src/main/java/jenkins/management/ConfigureLink.java @@ -30,7 +30,7 @@ import jenkins.model.Jenkins; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -52,7 +52,7 @@ public String getDescription() { return Messages.ConfigureLink_Description(); } - @Nonnull + @NonNull @Override public Permission getRequiredPermission() { return Jenkins.READ; @@ -63,7 +63,7 @@ public String getUrlName() { return "configure"; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.CONFIGURATION; diff --git a/core/src/main/java/jenkins/management/ConsoleLink.java b/core/src/main/java/jenkins/management/ConsoleLink.java index 6ee5c326ae23..6e62d2c4e50a 100644 --- a/core/src/main/java/jenkins/management/ConsoleLink.java +++ b/core/src/main/java/jenkins/management/ConsoleLink.java @@ -30,7 +30,7 @@ import jenkins.model.Jenkins; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -62,7 +62,7 @@ public Permission getRequiredPermission() { return Jenkins.ADMINISTER; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.TOOLS; diff --git a/core/src/main/java/jenkins/management/NodesLink.java b/core/src/main/java/jenkins/management/NodesLink.java index 5c2efe9a6674..6e048a62e8b0 100644 --- a/core/src/main/java/jenkins/management/NodesLink.java +++ b/core/src/main/java/jenkins/management/NodesLink.java @@ -30,7 +30,7 @@ import jenkins.model.Jenkins; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -52,7 +52,7 @@ public String getDescription() { return Messages.NodesLink_Description(); } - @Nonnull + @NonNull @Override public Permission getRequiredPermission() { return Jenkins.MANAGE; @@ -63,7 +63,7 @@ public String getUrlName() { return "computer"; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.CONFIGURATION; diff --git a/core/src/main/java/jenkins/management/PluginsLink.java b/core/src/main/java/jenkins/management/PluginsLink.java index 807ffbd43c43..02446c2ca98e 100644 --- a/core/src/main/java/jenkins/management/PluginsLink.java +++ b/core/src/main/java/jenkins/management/PluginsLink.java @@ -28,7 +28,7 @@ import hudson.model.ManagementLink; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -55,7 +55,7 @@ public String getUrlName() { return "pluginManager"; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.CONFIGURATION; diff --git a/core/src/main/java/jenkins/management/ReloadLink.java b/core/src/main/java/jenkins/management/ReloadLink.java index 043ec60f19fe..7d229bb9c394 100644 --- a/core/src/main/java/jenkins/management/ReloadLink.java +++ b/core/src/main/java/jenkins/management/ReloadLink.java @@ -28,7 +28,7 @@ import hudson.model.ManagementLink; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -64,7 +64,7 @@ public boolean getRequiresPOST() { return true; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.TOOLS; diff --git a/core/src/main/java/jenkins/management/ShutdownLink.java b/core/src/main/java/jenkins/management/ShutdownLink.java index 4e0194f4726a..36f5f4c713f1 100644 --- a/core/src/main/java/jenkins/management/ShutdownLink.java +++ b/core/src/main/java/jenkins/management/ShutdownLink.java @@ -30,7 +30,7 @@ import jenkins.model.Jenkins; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -62,13 +62,13 @@ public boolean getRequiresPOST() { return true; } - @Nonnull + @NonNull @Override public Permission getRequiredPermission() { return Jenkins.MANAGE; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.TOOLS; diff --git a/core/src/main/java/jenkins/management/StatisticsLink.java b/core/src/main/java/jenkins/management/StatisticsLink.java index d6b76942dcbb..2fa557a01499 100644 --- a/core/src/main/java/jenkins/management/StatisticsLink.java +++ b/core/src/main/java/jenkins/management/StatisticsLink.java @@ -30,7 +30,7 @@ import jenkins.model.Jenkins; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -52,7 +52,7 @@ public String getDescription() { return Messages.StatisticsLink_Description(); } - @Nonnull + @NonNull @Override public Permission getRequiredPermission() { return Jenkins.MANAGE; @@ -63,7 +63,7 @@ public String getUrlName() { return "load-statistics"; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.STATUS; diff --git a/core/src/main/java/jenkins/management/SystemInfoLink.java b/core/src/main/java/jenkins/management/SystemInfoLink.java index 989077c9b8f0..c9c7c5e09e08 100644 --- a/core/src/main/java/jenkins/management/SystemInfoLink.java +++ b/core/src/main/java/jenkins/management/SystemInfoLink.java @@ -27,7 +27,7 @@ import hudson.Extension; import hudson.model.ManagementLink; import hudson.security.Permission; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import org.jenkinsci.Symbol; @@ -51,7 +51,7 @@ public String getDescription() { return Messages.SystemInfoLink_Description(); } - @Nonnull + @NonNull @Override public Permission getRequiredPermission() { //This link is displayed to any user with permission to access the management menu @@ -63,7 +63,7 @@ public String getUrlName() { return "systemInfo"; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.STATUS; diff --git a/core/src/main/java/jenkins/management/SystemLogLink.java b/core/src/main/java/jenkins/management/SystemLogLink.java index 2aca9d9314a9..f8c8e9e791fa 100644 --- a/core/src/main/java/jenkins/management/SystemLogLink.java +++ b/core/src/main/java/jenkins/management/SystemLogLink.java @@ -28,7 +28,7 @@ import hudson.model.ManagementLink; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * @author Nicolas De Loof @@ -55,7 +55,7 @@ public String getUrlName() { return "log"; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.STATUS; diff --git a/core/src/main/java/jenkins/model/ArtifactManager.java b/core/src/main/java/jenkins/model/ArtifactManager.java index 874d4e3a5841..b4669ed5e8c7 100644 --- a/core/src/main/java/jenkins/model/ArtifactManager.java +++ b/core/src/main/java/jenkins/model/ArtifactManager.java @@ -33,7 +33,7 @@ import hudson.tasks.ArtifactArchiver; import java.io.IOException; import java.util.Map; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.util.VirtualFile; /** @@ -48,7 +48,7 @@ public abstract class ArtifactManager { * The selected manager will be persisted inside a build, so the build reference should be {@code transient} (quasi-{@code final}) and restored here. * @param build a historical build with which this manager was associated */ - public abstract void onLoad(@Nonnull Run build); + public abstract void onLoad(@NonNull Run build); /** * Archive all configured artifacts from a build. diff --git a/core/src/main/java/jenkins/model/ArtifactManagerConfiguration.java b/core/src/main/java/jenkins/model/ArtifactManagerConfiguration.java index 3b5ce11b8e84..8dc41f13a8c0 100644 --- a/core/src/main/java/jenkins/model/ArtifactManagerConfiguration.java +++ b/core/src/main/java/jenkins/model/ArtifactManagerConfiguration.java @@ -32,7 +32,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * List of configured {@link ArtifactManagerFactory}s. @@ -41,7 +41,7 @@ @Extension @Symbol("artifactManager") public class ArtifactManagerConfiguration extends GlobalConfiguration implements PersistentDescriptor { - public static @Nonnull ArtifactManagerConfiguration get() { + public static @NonNull ArtifactManagerConfiguration get() { return GlobalConfiguration.all().getInstance(ArtifactManagerConfiguration.class); } diff --git a/core/src/main/java/jenkins/model/ArtifactManagerFactory.java b/core/src/main/java/jenkins/model/ArtifactManagerFactory.java index efff30c5654d..ebb8708e969e 100644 --- a/core/src/main/java/jenkins/model/ArtifactManagerFactory.java +++ b/core/src/main/java/jenkins/model/ArtifactManagerFactory.java @@ -27,7 +27,7 @@ import hudson.ExtensionPoint; import hudson.model.AbstractDescribableImpl; import hudson.model.Run; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.kohsuke.stapler.DataBoundConstructor; /** diff --git a/core/src/main/java/jenkins/model/AssetManager.java b/core/src/main/java/jenkins/model/AssetManager.java index 4a7513c8b22a..a688f0f718ae 100644 --- a/core/src/main/java/jenkins/model/AssetManager.java +++ b/core/src/main/java/jenkins/model/AssetManager.java @@ -9,8 +9,8 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -78,7 +78,7 @@ public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOExceptio * look for child classloader first. But to support plugins that get split, if the child classloader * doesn't find it, fall back to the parent classloader. */ - private @CheckForNull URL findResource(@Nonnull String path) throws IOException { + private @CheckForNull URL findResource(@NonNull String path) throws IOException { if (StringUtils.isBlank(path)) { return null; } diff --git a/core/src/main/java/jenkins/model/BlockedBecauseOfBuildInProgress.java b/core/src/main/java/jenkins/model/BlockedBecauseOfBuildInProgress.java index 9abdd8fa8870..2710667a6d0c 100644 --- a/core/src/main/java/jenkins/model/BlockedBecauseOfBuildInProgress.java +++ b/core/src/main/java/jenkins/model/BlockedBecauseOfBuildInProgress.java @@ -28,7 +28,7 @@ import hudson.model.Job; import hudson.model.Run; import hudson.model.queue.CauseOfBlockage; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Indicates that a new build is blocked because the previous build is already in progress. @@ -37,14 +37,14 @@ */ public class BlockedBecauseOfBuildInProgress extends CauseOfBlockage { - @Nonnull + @NonNull private final Run build; /** * Creates a cause for the specified build. * @param build Build, which is already in progress */ - public BlockedBecauseOfBuildInProgress(@Nonnull Run build) { + public BlockedBecauseOfBuildInProgress(@NonNull Run build) { this.build = build; } diff --git a/core/src/main/java/jenkins/model/CauseOfInterruption.java b/core/src/main/java/jenkins/model/CauseOfInterruption.java index cce7987fc130..38b12cc86f30 100644 --- a/core/src/main/java/jenkins/model/CauseOfInterruption.java +++ b/core/src/main/java/jenkins/model/CauseOfInterruption.java @@ -33,8 +33,8 @@ import java.io.Serializable; import java.util.Collections; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Records why an {@linkplain Executor#interrupt() executor is interrupted}. @@ -77,14 +77,14 @@ public void print(TaskListener listener) { */ public static final class UserInterruption extends CauseOfInterruption { - @Nonnull + @NonNull private final String user; - public UserInterruption(@Nonnull User user) { + public UserInterruption(@NonNull User user) { this.user = user.getId(); } - public UserInterruption(@Nonnull String userId) { + public UserInterruption(@NonNull String userId) { this.user = userId; } @@ -93,7 +93,7 @@ public UserInterruption(@Nonnull String userId) { * @return User ID * @since 2.31 */ - @Nonnull + @NonNull public String getUserId() { return user; } @@ -103,7 +103,7 @@ public String getUserId() { * @return User instance if it can be located. * Result of {@link User#getUnknown()} otherwise */ - @Nonnull + @NonNull public User getUser() { final User userInstance = getUserOrNull(); return userInstance != null ? userInstance : User.getUnknown(); diff --git a/core/src/main/java/jenkins/model/FingerprintFacet.java b/core/src/main/java/jenkins/model/FingerprintFacet.java index cf8d2a540d62..c6b25e4fc30b 100644 --- a/core/src/main/java/jenkins/model/FingerprintFacet.java +++ b/core/src/main/java/jenkins/model/FingerprintFacet.java @@ -30,7 +30,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import java.util.List; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Plugin-specific additions to fingerprint information. @@ -67,7 +67,7 @@ public abstract class FingerprintFacet implements ExtensionPoint { * @param timestamp * Timestamp when the use happened (when the facet has been created). */ - protected FingerprintFacet(@Nonnull Fingerprint fingerprint, long timestamp) { + protected FingerprintFacet(@NonNull Fingerprint fingerprint, long timestamp) { assert fingerprint!=null; this.fingerprint = fingerprint; this.timestamp = timestamp; @@ -79,7 +79,7 @@ protected FingerprintFacet(@Nonnull Fingerprint fingerprint, long timestamp) { * @return * always non-null. */ - public @Nonnull Fingerprint getFingerprint() { + public @NonNull Fingerprint getFingerprint() { return fingerprint; } diff --git a/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java b/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java index 9ac2222ad577..4ba11f5c0ce5 100644 --- a/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java +++ b/core/src/main/java/jenkins/model/GlobalCloudConfiguration.java @@ -14,7 +14,7 @@ import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.verb.POST; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.ServletException; import java.io.IOException; diff --git a/core/src/main/java/jenkins/model/GlobalConfiguration.java b/core/src/main/java/jenkins/model/GlobalConfiguration.java index 4a261cbed5d8..dea390902f06 100644 --- a/core/src/main/java/jenkins/model/GlobalConfiguration.java +++ b/core/src/main/java/jenkins/model/GlobalConfiguration.java @@ -7,7 +7,7 @@ import net.sf.json.JSONObject; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Convenient base class for extensions that contributes to the system configuration page but nothing @@ -71,7 +71,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti /** * Returns all the registered {@link GlobalConfiguration} descriptors. */ - public static @Nonnull ExtensionList all() { + public static @NonNull ExtensionList all() { return Jenkins.get().getDescriptorList(GlobalConfiguration.class); // pointless type parameters help work around bugs in javac in earlier versions http://codepad.org/m1bbFRrH } diff --git a/core/src/main/java/jenkins/model/GlobalConfigurationCategory.java b/core/src/main/java/jenkins/model/GlobalConfigurationCategory.java index 5164f171e468..6805414d1fb4 100644 --- a/core/src/main/java/jenkins/model/GlobalConfigurationCategory.java +++ b/core/src/main/java/jenkins/model/GlobalConfigurationCategory.java @@ -6,7 +6,7 @@ import hudson.model.ModelObject; import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Grouping of related {@link GlobalConfiguration}s. @@ -41,7 +41,7 @@ public static ExtensionList all() { return ExtensionList.lookup(GlobalConfigurationCategory.class); } - public static @Nonnull T get(Class type) { + public static @NonNull T get(Class type) { T category = all().get(type); if(category == null){ throw new AssertionError("Category not found. It seems the " + type + " is not annotated with @Extension and so not registered"); diff --git a/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java b/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java index f4af422543e7..3ded68b17348 100644 --- a/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java +++ b/core/src/main/java/jenkins/model/GlobalProjectNamingStrategyConfiguration.java @@ -31,7 +31,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Configures the project naming strategy. @@ -63,7 +63,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws hudson.mode return true; } - @Nonnull + @NonNull @Override public Permission getRequiredGlobalConfigPagePermission() { return Jenkins.MANAGE; diff --git a/core/src/main/java/jenkins/model/GlobalQuietPeriodConfiguration.java b/core/src/main/java/jenkins/model/GlobalQuietPeriodConfiguration.java index 92a463e73360..a7035f5f860d 100644 --- a/core/src/main/java/jenkins/model/GlobalQuietPeriodConfiguration.java +++ b/core/src/main/java/jenkins/model/GlobalQuietPeriodConfiguration.java @@ -29,7 +29,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; /** @@ -60,7 +60,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti } } - @Nonnull + @NonNull @Override public Permission getRequiredGlobalConfigPagePermission() { return Jenkins.MANAGE; diff --git a/core/src/main/java/jenkins/model/GlobalSCMRetryCountConfiguration.java b/core/src/main/java/jenkins/model/GlobalSCMRetryCountConfiguration.java index 3ec65ff2e3e9..a5ed8681a905 100644 --- a/core/src/main/java/jenkins/model/GlobalSCMRetryCountConfiguration.java +++ b/core/src/main/java/jenkins/model/GlobalSCMRetryCountConfiguration.java @@ -30,7 +30,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; /** @@ -57,7 +57,7 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti } } - @Nonnull + @NonNull @Override public Permission getRequiredGlobalConfigPagePermission() { return Jenkins.MANAGE; diff --git a/core/src/main/java/jenkins/model/IdStrategy.java b/core/src/main/java/jenkins/model/IdStrategy.java index e434343f74f9..673987eb9ac4 100644 --- a/core/src/main/java/jenkins/model/IdStrategy.java +++ b/core/src/main/java/jenkins/model/IdStrategy.java @@ -34,7 +34,7 @@ import org.kohsuke.accmod.restrictions.ProtectedExternally; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.Serializable; import java.util.Comparator; import java.util.Locale; @@ -66,7 +66,7 @@ public abstract class IdStrategy extends AbstractDescribableImpl imp * @deprecated No current use. */ @Deprecated - public String filenameOf(@Nonnull String id) { + public String filenameOf(@NonNull String id) { return null; } @@ -79,7 +79,7 @@ public String filenameOf(@Nonnull String id) { */ @Deprecated @Restricted(ProtectedExternally.class) - public String legacyFilenameOf(@Nonnull String id) { + public String legacyFilenameOf(@NonNull String id) { return null; } @@ -92,7 +92,7 @@ public String legacyFilenameOf(@Nonnull String id) { * @deprecated Use only for migrating to new format. After the migration an id is no longer represented by a filename (directory). */ @Deprecated - public String idFromFilename(@Nonnull String filename) { + public String idFromFilename(@NonNull String filename) { return filename; } @@ -103,8 +103,8 @@ public String idFromFilename(@Nonnull String filename) { * @param id the id. * @return the key. */ - @Nonnull - public String keyFor(@Nonnull String id) { + @NonNull + public String keyFor(@NonNull String id) { return id; } @@ -117,7 +117,7 @@ public String keyFor(@Nonnull String id) { * @param id2 the second id. * @return {@code true} if and only if the two ids are the same. */ - public boolean equals(@Nonnull String id1, @Nonnull String id2) { + public boolean equals(@NonNull String id1, @NonNull String id2) { return compare(id1, id2) == 0; } @@ -131,7 +131,7 @@ public boolean equals(@Nonnull String id1, @Nonnull String id2) { * @return the sorting order of the two IDs. */ @Override - public abstract int compare(@Nonnull String id1, @Nonnull String id2); + public abstract int compare(@NonNull String id1, @NonNull String id2); @Override @SuppressWarnings("unchecked") @@ -167,8 +167,8 @@ public static DescriptorExtensionList all() { return Jenkins.get().getDescriptorList(IdStrategy.class); } - String applyPatternRepeatedly(@Nonnull Pattern pattern, @Nonnull String filename, - @Nonnull Function converter) { + String applyPatternRepeatedly(@NonNull Pattern pattern, @NonNull String filename, + @NonNull Function converter) { StringBuilder id = new StringBuilder(); int beginIndex = 0; Matcher matcher = pattern.matcher(filename); @@ -197,26 +197,26 @@ public static class CaseInsensitive extends IdStrategy implements Serializable { public CaseInsensitive() {} @Override - public String idFromFilename(@Nonnull String filename) { + public String idFromFilename(@NonNull String filename) { String id = applyPatternRepeatedly(PSEUDO_UNICODE_PATTERN, filename, this::convertPseudoUnicode); return id.toLowerCase(Locale.ENGLISH); } @Override - @Nonnull - public String keyFor(@Nonnull String id) { + @NonNull + public String keyFor(@NonNull String id) { return id.toLowerCase(Locale.ENGLISH); } @Override - public int compare(@Nonnull String id1, @Nonnull String id2) { + public int compare(@NonNull String id1, @NonNull String id2) { return CaseInsensitiveComparator.INSTANCE.compare(id1, id2); } @Extension @Symbol("caseInsensitive") public static class DescriptorImpl extends IdStrategyDescriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return Messages.IdStrategy_CaseInsensitive_DisplayName(); @@ -235,7 +235,7 @@ public static class CaseSensitive extends IdStrategy implements Serializable { public CaseSensitive() {} @Override - public String idFromFilename(@Nonnull String filename) { + public String idFromFilename(@NonNull String filename) { String id = applyPatternRepeatedly(CAPITALIZATION_PATTERN, filename, this::convertCapitalizedAscii); return applyPatternRepeatedly(PSEUDO_UNICODE_PATTERN, id, this::convertPseudoUnicode); } @@ -245,12 +245,12 @@ private Character convertCapitalizedAscii(String encoded) { } @Override - public boolean equals(@Nonnull String id1, @Nonnull String id2) { + public boolean equals(@NonNull String id1, @NonNull String id2) { return StringUtils.equals(id1, id2); } @Override - public int compare(@Nonnull String id1, @Nonnull String id2) { + public int compare(@NonNull String id1, @NonNull String id2) { return id1.compareTo(id2); } @@ -281,20 +281,20 @@ public static class CaseSensitiveEmailAddress extends CaseSensitive implements S public CaseSensitiveEmailAddress() {} @Override - public boolean equals(@Nonnull String id1, @Nonnull String id2) { + public boolean equals(@NonNull String id1, @NonNull String id2) { return StringUtils.equals(keyFor(id1), keyFor(id2)); } @Override - @Nonnull - public String keyFor(@Nonnull String id) { + @NonNull + public String keyFor(@NonNull String id) { int index = id.lastIndexOf('@'); // The @ can be used in local-part if quoted correctly // => the last @ is the one used to separate the domain and local-part return index == -1 ? id : id.substring(0, index) + (id.substring(index).toLowerCase(Locale.ENGLISH)); } @Override - public int compare(@Nonnull String id1, @Nonnull String id2) { + public int compare(@NonNull String id1, @NonNull String id2) { return keyFor(id1).compareTo(keyFor(id2)); } diff --git a/core/src/main/java/jenkins/model/Jenkins.java b/core/src/main/java/jenkins/model/Jenkins.java index 094551db74ba..465a5e0ff51d 100644 --- a/core/src/main/java/jenkins/model/Jenkins.java +++ b/core/src/main/java/jenkins/model/Jenkins.java @@ -250,9 +250,9 @@ import org.kohsuke.stapler.verb.POST; import org.xml.sax.InputSource; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import javax.crypto.SecretKey; import javax.servlet.RequestDispatcher; import javax.servlet.ServletContext; @@ -306,7 +306,6 @@ import hudson.init.Initializer; import hudson.util.LogTaskListener; import static java.util.logging.Level.*; -import javax.annotation.Nonnegative; import static javax.servlet.http.HttpServletResponse.*; import org.kohsuke.accmod.restrictions.DoNotUse; import org.kohsuke.stapler.WebMethod; @@ -772,7 +771,7 @@ public interface JenkinsHolder { * @throws IllegalStateException for the reasons that {@link #getInstanceOrNull} might return null * @since 2.98 */ - @Nonnull + @NonNull public static Jenkins get() throws IllegalStateException { Jenkins instance = getInstanceOrNull(); if (instance == null) { @@ -786,7 +785,7 @@ public static Jenkins get() throws IllegalStateException { * @since 1.590 */ @Deprecated - @Nonnull + @NonNull public static Jenkins getActiveInstance() throws IllegalStateException { return get(); } @@ -1082,7 +1081,7 @@ public void setProxy(@CheckForNull ProxyConfiguration proxy) { * Get the Jenkins {@link jenkins.install.InstallState install state}. * @return The Jenkins {@link jenkins.install.InstallState install state}. */ - @Nonnull + @NonNull public InstallState getInstallState() { if (installState != null) { installStateName = installState.name(); @@ -1096,7 +1095,7 @@ public InstallState getInstallState() { * Update the current install state. This will invoke state.initializeState() * when the state has been transitioned. */ - public void setInstallState(@Nonnull InstallState newState) { + public void setInstallState(@NonNull InstallState newState) { String prior = installStateName; installStateName = newState.name(); LOGGER.log(Main.isDevelopmentMode ? Level.INFO : Level.FINE, "Install state transitioning from: {0} to : {1}", new Object[] { prior, installStateName }); @@ -1364,7 +1363,7 @@ public String getDescription() { return systemMessage; } - @Nonnull + @NonNull public PluginManager getPluginManager() { return pluginManager; } @@ -1597,7 +1596,7 @@ public Descriptor getDescriptor(Class type) { * If the descriptor is missing. * @since 1.326 */ - @Nonnull + @NonNull public Descriptor getDescriptorOrDie(Class type) { Descriptor d = getDescriptor(type); if (d==null) @@ -1712,7 +1711,7 @@ public String getSystemMessage() { * never null. * @since 1.391 */ - public @Nonnull MarkupFormatter getMarkupFormatter() { + public @NonNull MarkupFormatter getMarkupFormatter() { MarkupFormatter f = markupFormatter; return f != null ? f : new EscapedMarkupFormatter(); } @@ -1932,7 +1931,7 @@ public View getPrimaryView() { return viewGroupMixIn.getPrimaryView(); } - public void setPrimaryView(@Nonnull View v) { + public void setPrimaryView(@NonNull View v) { this.primaryView = v.getViewName(); } @@ -1995,7 +1994,7 @@ public Computer[] getComputers() { } @CLIResolver - public @CheckForNull Computer getComputer(@Argument(required=true,metaVar="NAME",usage="Node name") @Nonnull String name) { + public @CheckForNull Computer getComputer(@Argument(required=true,metaVar="NAME",usage="Node name") @NonNull String name) { if(name.equals("(master)")) name = ""; @@ -2139,7 +2138,7 @@ protected Map getComputerMap() { * Returns all {@link Node}s in the system, excluding {@link Jenkins} instance itself which * represents the master. */ - @Nonnull + @NonNull public List getNodes() { return nodes.getNodes(); } @@ -2165,7 +2164,7 @@ public void addNode(Node n) throws IOException { /** * Removes a {@link Node} from Jenkins. */ - public void removeNode(@Nonnull Node n) throws IOException { + public void removeNode(@NonNull Node n) throws IOException { nodes.removeNode(n); } @@ -2310,7 +2309,7 @@ public SearchIndexBuilder makeSearchIndex() { builder.add(new CollectionSearchIndex() { protected SearchItem get(String key) { return getItemByFullName(key, TopLevelItem.class); } protected Collection all() { return getAllItems(TopLevelItem.class); } - @Nonnull + @NonNull @Override protected Iterable allAsIterable() { return allItems(TopLevelItem.class); @@ -2406,7 +2405,7 @@ public boolean isRootUrlSecure() { * shows some examples of configuration. * @since 1.263 */ - public @Nonnull String getRootUrlFromRequest() { + public @NonNull String getRootUrlFromRequest() { StaplerRequest req = Stapler.getCurrentRequest(); if (req == null) { throw new IllegalStateException("cannot call getRootUrlFromRequest from outside a request handling thread"); @@ -2531,7 +2530,7 @@ public void setRawBuildsDir(String buildsDir) { this.buildsDir = buildsDir; } - @Override public @Nonnull FilePath getRootPath() { + @Override public @NonNull FilePath getRootPath() { return new FilePath(getRootDir()); } @@ -2725,7 +2724,7 @@ public ExtensionList getExtensionList(String extensionType) throws ClassNotFound * Can be an empty list but never null. */ @SuppressWarnings({"unchecked"}) - public @Nonnull ,D extends Descriptor> DescriptorExtensionList getDescriptorList(Class type) { + public @NonNull ,D extends Descriptor> DescriptorExtensionList getDescriptorList(Class type) { return descriptorLists.computeIfAbsent(type, key -> DescriptorExtensionList.createDescriptorList(this, key)); } @@ -2833,7 +2832,7 @@ public InitMilestone getInitLevel() { * @throws IOException Failed to save the configuration * @throws IllegalArgumentException Negative value has been passed */ - public void setNumExecutors(@Nonnegative int n) throws IOException, IllegalArgumentException { + public void setNumExecutors(/* @javax.annotation.Nonnegative*/ int n) throws IOException, IllegalArgumentException { if (n < 0) { throw new IllegalArgumentException("Incorrect field \"# of executors\": " + n +". It should be a non-negative number."); } @@ -2928,7 +2927,7 @@ public final Item getItem(String pathName, Item context) { return getItem(pathName,context!=null?context.getParent():null); } - public final T getItem(String pathName, ItemGroup context, @Nonnull Class type) { + public final T getItem(String pathName, ItemGroup context, @NonNull Class type) { Item r = getItem(pathName, context); if (type.isInstance(r)) return type.cast(r); @@ -2957,7 +2956,7 @@ private File getRootDirFor(String name) { * or it exists but it's no an instance of the given type. * @throws AccessDeniedException as per {@link ItemGroup#getItem} */ - public @CheckForNull T getItemByFullName(@Nonnull String fullName, Class type) throws AccessDeniedException { + public @CheckForNull T getItemByFullName(@NonNull String fullName, Class type) throws AccessDeniedException { StringTokenizer tokens = new StringTokenizer(fullName,"/"); ItemGroup parent = this; @@ -3133,7 +3132,7 @@ public LabelAtom getSelfLabel() { } @Override - @Nonnull + @NonNull public Computer createComputer() { return new Hudson.MasterComputer(); } @@ -4468,7 +4467,7 @@ public void run() { * Gets the {@link Authentication} object that represents the user * associated with the current request. */ - public static @Nonnull Authentication getAuthentication() { + public static @NonNull Authentication getAuthentication() { Authentication a = SecurityContextHolder.getContext().getAuthentication(); // on Tomcat while serving the login page, this is null despite the fact // that we have filters. Looking at the stack trace, Tomcat doesn't seem to diff --git a/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java b/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java index 4f526e97749a..21d49c0d2513 100644 --- a/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java +++ b/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java @@ -14,7 +14,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.QueryParameter; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.servlet.ServletContext; @@ -26,8 +26,8 @@ import java.util.logging.Logger; import static hudson.Util.fixNull; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Stores the location of Jenkins (e-mail address and the HTTP URL.) @@ -64,7 +64,7 @@ public class JenkinsLocationConfiguration extends GlobalConfiguration implements // just to suppress warnings private transient String charset,useSsl; - public static @Nonnull JenkinsLocationConfiguration get() { + public static @NonNull JenkinsLocationConfiguration get() { return GlobalConfiguration.all().getInstance(JenkinsLocationConfiguration.class); } @@ -72,7 +72,7 @@ public class JenkinsLocationConfiguration extends GlobalConfiguration implements * Gets local configuration. For explanation when it could die, see {@link #get()} */ @Restricted(NoExternalUse.class) - public static @Nonnull JenkinsLocationConfiguration getOrDie(){ + public static @NonNull JenkinsLocationConfiguration getOrDie(){ JenkinsLocationConfiguration config = JenkinsLocationConfiguration.get(); if (config == null) { throw new IllegalStateException("JenkinsLocationConfiguration instance is missing. Probably the Jenkins instance is not fully loaded at this time."); @@ -113,7 +113,7 @@ public synchronized void load() { * Gets the service administrator e-mail address. * @return Admin address or "address not configured" stub */ - public @Nonnull String getAdminAddress() { + public @NonNull String getAdminAddress() { String v = adminAddress; if(v==null) v = Messages.Mailer_Address_Not_Configured(); return v; diff --git a/core/src/main/java/jenkins/model/JobGlobalBuildDiscarderStrategy.java b/core/src/main/java/jenkins/model/JobGlobalBuildDiscarderStrategy.java index bb5523f68bc6..8260af8c34f8 100644 --- a/core/src/main/java/jenkins/model/JobGlobalBuildDiscarderStrategy.java +++ b/core/src/main/java/jenkins/model/JobGlobalBuildDiscarderStrategy.java @@ -30,7 +30,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; /** @@ -56,7 +56,7 @@ public void apply(Job job) throws IOException, InterruptedException { @Extension @Symbol("jobBuildDiscarder") public static class DescriptorImpl extends GlobalBuildDiscarderStrategyDescriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return Messages.JobGlobalBuildDiscarderStrategy_displayName(); diff --git a/core/src/main/java/jenkins/model/NodeListener.java b/core/src/main/java/jenkins/model/NodeListener.java index 43d269229227..cc569e18ece6 100644 --- a/core/src/main/java/jenkins/model/NodeListener.java +++ b/core/src/main/java/jenkins/model/NodeListener.java @@ -27,7 +27,7 @@ import hudson.ExtensionPoint; import hudson.model.Node; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -45,24 +45,24 @@ public abstract class NodeListener implements ExtensionPoint { /** * Node is being created. */ - protected void onCreated(@Nonnull Node node) {} + protected void onCreated(@NonNull Node node) {} /** * Node is being updated. */ - protected void onUpdated(@Nonnull Node oldOne, @Nonnull Node newOne) {} + protected void onUpdated(@NonNull Node oldOne, @NonNull Node newOne) {} /** * Node is being deleted. */ - protected void onDeleted(@Nonnull Node node) {} + protected void onDeleted(@NonNull Node node) {} /** * Inform listeners that node is being created. * * @param node A node being created. */ - public static void fireOnCreated(@Nonnull Node node) { + public static void fireOnCreated(@NonNull Node node) { for (NodeListener nl: all()) { try { nl.onCreated(node); @@ -78,7 +78,7 @@ public static void fireOnCreated(@Nonnull Node node) { * @param oldOne Old configuration. * @param newOne New Configuration. */ - public static void fireOnUpdated(@Nonnull Node oldOne, @Nonnull Node newOne) { + public static void fireOnUpdated(@NonNull Node oldOne, @NonNull Node newOne) { for (NodeListener nl: all()) { try { nl.onUpdated(oldOne, newOne); @@ -93,7 +93,7 @@ public static void fireOnUpdated(@Nonnull Node oldOne, @Nonnull Node newOne) { * * @param node A node being removed. */ - public static void fireOnDeleted(@Nonnull Node node) { + public static void fireOnDeleted(@NonNull Node node) { for (NodeListener nl: all()) { try { nl.onDeleted(node); @@ -106,7 +106,7 @@ public static void fireOnDeleted(@Nonnull Node node) { /** * Get all {@link NodeListener}s registered in Jenkins. */ - public static @Nonnull List all() { + public static @NonNull List all() { return ExtensionList.lookup(NodeListener.class); } } diff --git a/core/src/main/java/jenkins/model/Nodes.java b/core/src/main/java/jenkins/model/Nodes.java index 648c867c4b52..ed7c73ee46fb 100644 --- a/core/src/main/java/jenkins/model/Nodes.java +++ b/core/src/main/java/jenkins/model/Nodes.java @@ -38,8 +38,8 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.File; import java.io.FileFilter; import java.io.IOException; @@ -67,7 +67,7 @@ public class Nodes implements Saveable { /** * The {@link Jenkins} instance that we are tracking nodes for. */ - @Nonnull + @NonNull private final Jenkins jenkins; /** @@ -82,7 +82,7 @@ public class Nodes implements Saveable { * let this reference escape from a partially constructed {@link Nodes} as when we are passed the * reference the {@link Jenkins} instance has not completed instantiation. */ - /*package*/ Nodes(@Nonnull Jenkins jenkins) { + /*package*/ Nodes(@NonNull Jenkins jenkins) { this.jenkins = jenkins; } @@ -91,7 +91,7 @@ public class Nodes implements Saveable { * * @return the list of nodes. */ - @Nonnull + @NonNull public List getNodes() { return new ArrayList<>(nodes.values()); } @@ -102,7 +102,7 @@ public List getNodes() { * @param nodes the new list of nodes. * @throws IOException if the new list of nodes could not be persisted. */ - public void setNodes(final @Nonnull Collection nodes) throws IOException { + public void setNodes(final @NonNull Collection nodes) throws IOException { Queue.withLock(new Runnable() { @Override public void run() { @@ -126,7 +126,7 @@ public void run() { * @param node the new node. * @throws IOException if the list of nodes could not be persisted. */ - public void addNode(final @Nonnull Node node) throws IOException { + public void addNode(final @NonNull Node node) throws IOException { Node oldNode = nodes.get(node.getNodeName()); if (node != oldNode) { // TODO we should not need to lock the queue for adding nodes but until we have a way to update the @@ -170,7 +170,7 @@ public void run() { * @param node the node to be persisted. * @throws IOException if the node could not be persisted. */ - private void persistNode(final @Nonnull Node node) throws IOException { + private void persistNode(final @NonNull Node node) throws IOException { // no need for a full save() so we just do the minimum if (node instanceof EphemeralNode) { Util.deleteRecursive(new File(getNodesDir(), node.getNodeName())); @@ -192,7 +192,7 @@ private void persistNode(final @Nonnull Node node) throws IOException { * @throws IOException if the node could not be persisted. * @since 1.634 */ - public boolean updateNode(final @Nonnull Node node) throws IOException { + public boolean updateNode(final @NonNull Node node) throws IOException { boolean exists; try { exists = Queue.withLock(new Callable() { @@ -227,7 +227,7 @@ public Boolean call() throws Exception { * @return {@code true} if node was replaced. * @since 2.8 */ - public boolean replaceNode(final Node oldOne, final @Nonnull Node newOne) throws IOException { + public boolean replaceNode(final Node oldOne, final @NonNull Node newOne) throws IOException { if (oldOne == nodes.get(oldOne.getNodeName())) { // use the queue lock until Nodes has a way of directly modifying a single node. Queue.withLock(new Runnable() { @@ -257,7 +257,7 @@ public void run() { * @param node the node instance to remove. * @throws IOException if the list of nodes could not be persisted. */ - public void removeNode(final @Nonnull Node node) throws IOException { + public void removeNode(final @NonNull Node node) throws IOException { if (node == nodes.get(node.getNodeName())) { Queue.withLock(new Runnable() { @Override diff --git a/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java b/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java index 0e814da55557..46fcb49ef0b7 100644 --- a/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java +++ b/core/src/main/java/jenkins/model/ParameterizedJobMixIn.java @@ -54,7 +54,7 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.ServletException; import static javax.servlet.http.HttpServletResponse.SC_CREATED; import static javax.servlet.http.HttpServletResponse.SC_CONFLICT; diff --git a/core/src/main/java/jenkins/model/PeepholePermalink.java b/core/src/main/java/jenkins/model/PeepholePermalink.java index 8029524c993e..cd2f5c5c6793 100644 --- a/core/src/main/java/jenkins/model/PeepholePermalink.java +++ b/core/src/main/java/jenkins/model/PeepholePermalink.java @@ -19,8 +19,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Stream; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Convenient base implementation for {@link Permalink}s that satisfy @@ -130,7 +130,7 @@ private Run find(Run b) { return b; } - private static @Nonnull Map cacheFor(@Nonnull File buildDir) { + private static @NonNull Map cacheFor(@NonNull File buildDir) { synchronized (caches) { Map cache = caches.get(buildDir); if (cache == null) { @@ -141,7 +141,7 @@ private Run find(Run b) { } } - private static @Nonnull Map load(@Nonnull File buildDir) { + private static @NonNull Map load(@NonNull File buildDir) { Map cache = new TreeMap<>(); File storage = storageFor(buildDir); if (storage.isFile()) { @@ -165,14 +165,14 @@ private Run find(Run b) { return cache; } - static @Nonnull File storageFor(@Nonnull File buildDir) { + static @NonNull File storageFor(@NonNull File buildDir) { return new File(buildDir, "permalinks"); } /** * Remembers the value 'n' in the cache for future {@link #resolve(Job)}. */ - protected void updateCache(@Nonnull Job job, @CheckForNull Run b) { + protected void updateCache(@NonNull Job job, @CheckForNull Run b) { File buildDir = job.getBuildDir(); Map cache = cacheFor(buildDir); synchronized (cache) { @@ -218,7 +218,7 @@ public void onDeleted(Run run) { * See if the new build matches any of the peephole permalink. */ @Override - public void onCompleted(Run run, @Nonnull TaskListener listener) { + public void onCompleted(Run run, @NonNull TaskListener listener) { Job j = run.getParent(); for (PeepholePermalink pp : Util.filter(j.getPermalinks(), PeepholePermalink.class)) { if (pp.apply(run)) { diff --git a/core/src/main/java/jenkins/model/RunIdMigrator.java b/core/src/main/java/jenkins/model/RunIdMigrator.java index 0f08bdfa268b..5dde1c0e244a 100644 --- a/core/src/main/java/jenkins/model/RunIdMigrator.java +++ b/core/src/main/java/jenkins/model/RunIdMigrator.java @@ -54,8 +54,8 @@ import java.util.logging.Logger; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.apache.commons.io.Charsets; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.time.FastDateFormat; @@ -89,7 +89,7 @@ public final class RunIdMigrator { */ private static final Set offeredToUnmigrate = Collections.synchronizedSet(new HashSet<>()); - private @Nonnull Map idToNumber = EMPTY; + private @NonNull Map idToNumber = EMPTY; public RunIdMigrator() {} @@ -290,7 +290,7 @@ static void move(File src, File dest) throws IOException { * @param id a nonnumeric ID which may be a valid {@link Run#getId} * @return the corresponding {@link Run#number}, or 0 if unknown */ - public synchronized int findNumber(@Nonnull String id) { + public synchronized int findNumber(@NonNull String id) { Integer number = idToNumber.get(id); return number != null ? number : 0; } diff --git a/core/src/main/java/jenkins/model/SimpleGlobalBuildDiscarderStrategy.java b/core/src/main/java/jenkins/model/SimpleGlobalBuildDiscarderStrategy.java index 5b4f68ede397..fd2357eb5bf4 100644 --- a/core/src/main/java/jenkins/model/SimpleGlobalBuildDiscarderStrategy.java +++ b/core/src/main/java/jenkins/model/SimpleGlobalBuildDiscarderStrategy.java @@ -30,7 +30,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; /** @@ -65,7 +65,7 @@ public void apply(Job job) throws IOException, InterruptedException { @Extension @Symbol("simpleBuildDiscarder") public static class DescriptorImpl extends GlobalBuildDiscarderStrategyDescriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return Messages.SimpleGlobalBuildDiscarderStrategy_displayName(); diff --git a/core/src/main/java/jenkins/model/TransientActionFactory.java b/core/src/main/java/jenkins/model/TransientActionFactory.java index b3d0579abce0..4a5361eec740 100644 --- a/core/src/main/java/jenkins/model/TransientActionFactory.java +++ b/core/src/main/java/jenkins/model/TransientActionFactory.java @@ -37,7 +37,7 @@ import java.util.Collection; import java.util.Collections; import java.util.List; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -78,7 +78,7 @@ public abstract class TransientActionFactory implements ExtensionPoint { * @param target an actionable object * @return a possible empty set of actions (typically either using {@link Collections#emptySet} or {@link Collections#singleton}) */ - public abstract @Nonnull Collection createFor(@Nonnull T target); + public abstract @NonNull Collection createFor(@NonNull T target); /** @see no pairs/tuples in Java */ private static class CacheKey { diff --git a/core/src/main/java/jenkins/model/identity/InstanceIdentityProvider.java b/core/src/main/java/jenkins/model/identity/InstanceIdentityProvider.java index c65e27fa9081..489d1373220b 100644 --- a/core/src/main/java/jenkins/model/identity/InstanceIdentityProvider.java +++ b/core/src/main/java/jenkins/model/identity/InstanceIdentityProvider.java @@ -37,8 +37,8 @@ import java.security.interfaces.RSAPublicKey; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * A source of instance identity. @@ -151,7 +151,7 @@ private KeyTypes(Class pubKeyType, Class privKeyType) { @CheckForNull @SuppressWarnings("unchecked") private static InstanceIdentityProvider get( - @Nonnull KeyTypes type) { + @NonNull KeyTypes type) { for (InstanceIdentityProvider provider : ExtensionList.lookup(InstanceIdentityProvider.class)) { try { KeyPair keyPair = provider.getKeyPair(); diff --git a/core/src/main/java/jenkins/model/item_category/Categories.java b/core/src/main/java/jenkins/model/item_category/Categories.java index 4ae25096e65d..46a01e07e1e8 100644 --- a/core/src/main/java/jenkins/model/item_category/Categories.java +++ b/core/src/main/java/jenkins/model/item_category/Categories.java @@ -33,8 +33,8 @@ import org.kohsuke.stapler.export.ExportedBean; import org.kohsuke.stapler.export.Flavor; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import java.io.IOException; import java.io.Serializable; @@ -69,7 +69,7 @@ public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object nod } @CheckForNull - public Category getItem(@Nonnull String id) { + public Category getItem(@NonNull String id) { for (Category category : items) { if (category.getId().equals(id)) { return category; diff --git a/core/src/main/java/jenkins/model/item_category/ItemCategory.java b/core/src/main/java/jenkins/model/item_category/ItemCategory.java index 1f80cc82a1b4..d81b632f2bde 100644 --- a/core/src/main/java/jenkins/model/item_category/ItemCategory.java +++ b/core/src/main/java/jenkins/model/item_category/ItemCategory.java @@ -29,7 +29,7 @@ import hudson.ExtensionPoint; import hudson.model.TopLevelItemDescriptor; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -95,7 +95,7 @@ public int getOrder() { * * @return A {@link ItemCategory}, if not found, {@link ItemCategory.UncategorizedCategory} is returned */ - @Nonnull + @NonNull public static ItemCategory getCategory(TopLevelItemDescriptor descriptor) { int order = 0; ExtensionList categories = ExtensionList.lookup(ItemCategory.class); diff --git a/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java b/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java index 3b8d2718c478..f2bc32b638dc 100644 --- a/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java +++ b/core/src/main/java/jenkins/model/lazy/AbstractLazyLoadRunMap.java @@ -39,7 +39,7 @@ import java.util.TreeMap; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.util.MemoryReductionUtil; import org.kohsuke.accmod.Restricted; diff --git a/core/src/main/java/jenkins/model/lazy/BuildReference.java b/core/src/main/java/jenkins/model/lazy/BuildReference.java index 0572ad549b61..97452cac3098 100644 --- a/core/src/main/java/jenkins/model/lazy/BuildReference.java +++ b/core/src/main/java/jenkins/model/lazy/BuildReference.java @@ -10,8 +10,8 @@ import java.lang.ref.WeakReference; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.lazy.LazyBuildMixIn.RunMixIn; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -108,7 +108,7 @@ public interface HolderFactory extends ExtensionPoint { * @param referent the thing to load * @return a reference, or null to consult the next factory */ - @CheckForNull Holder make(@Nonnull R referent); + @CheckForNull Holder make(@NonNull R referent); } diff --git a/core/src/main/java/jenkins/model/lazy/BuildReferenceMapAdapter.java b/core/src/main/java/jenkins/model/lazy/BuildReferenceMapAdapter.java index c17a9c647ff3..4b505ab9ccb4 100644 --- a/core/src/main/java/jenkins/model/lazy/BuildReferenceMapAdapter.java +++ b/core/src/main/java/jenkins/model/lazy/BuildReferenceMapAdapter.java @@ -4,7 +4,7 @@ import hudson.util.AdaptedIterator; import hudson.util.Iterators; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Collection; diff --git a/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java b/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java index 43a5c251c3ef..f1fd7b7ee98f 100644 --- a/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java +++ b/core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java @@ -41,8 +41,8 @@ import java.lang.reflect.InvocationTargetException; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.DoNotUse; @@ -62,7 +62,7 @@ public abstract class LazyBuildMixIn & Queue.Task & private static final Logger LOGGER = Logger.getLogger(LazyBuildMixIn.class.getName()); @SuppressWarnings("deprecation") // [JENKINS-15156] builds accessed before onLoad or onCreatedFromScratch called - private @Nonnull RunMap builds = new RunMap<>(); + private @NonNull RunMap builds = new RunMap<>(); /** * Initializes this mixin. @@ -77,7 +77,7 @@ protected LazyBuildMixIn() {} * Normally should not be called as such. * Note that the initial value is replaced during {@link #onCreatedFromScratch} or {@link #onLoad}. */ - public final @Nonnull RunMap getRunMap() { + public final @NonNull RunMap getRunMap() { return builds; } diff --git a/core/src/main/java/jenkins/model/queue/AsynchronousExecution.java b/core/src/main/java/jenkins/model/queue/AsynchronousExecution.java index 3da69e22177c..d554b2a1c170 100644 --- a/core/src/main/java/jenkins/model/queue/AsynchronousExecution.java +++ b/core/src/main/java/jenkins/model/queue/AsynchronousExecution.java @@ -34,9 +34,9 @@ import hudson.model.ResourceActivity; import hudson.model.ResourceController; import hudson.model.ResourceList; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.GuardedBy; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import net.jcip.annotations.GuardedBy; import jenkins.model.Jenkins; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -112,7 +112,7 @@ public synchronized final Executor getExecutor() { * after releasing any problematic locks. */ @Restricted(NoExternalUse.class) - public synchronized final void setExecutorWithoutCompleting(@Nonnull Executor executor) { + public synchronized final void setExecutorWithoutCompleting(@NonNull Executor executor) { assert this.executor == null; this.executor = executor; } diff --git a/core/src/main/java/jenkins/model/queue/ItemDeletion.java b/core/src/main/java/jenkins/model/queue/ItemDeletion.java index b86a93c2f052..e871264fa2d7 100644 --- a/core/src/main/java/jenkins/model/queue/ItemDeletion.java +++ b/core/src/main/java/jenkins/model/queue/ItemDeletion.java @@ -34,9 +34,9 @@ import java.util.Set; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.GuardedBy; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import net.jcip.annotations.GuardedBy; /** * A {@link Queue.QueueDecisionHandler} that blocks items being deleted from entering the queue. @@ -57,7 +57,7 @@ public class ItemDeletion extends Queue.QueueDecisionHandler { private final Set registrations = new HashSet<>(); @GuardedBy("lock") - private boolean _contains(@Nonnull Item item) { + private boolean _contains(@NonNull Item item) { if (registrations.isEmpty()) { // no point walking everything if there is nothing in-flight return false; @@ -82,7 +82,7 @@ private boolean _contains(@Nonnull Item item) { * @param item the item. * @return {@code true} if the {@link Item} or any of its {@link Item#getParent()} are being deleted. */ - public static boolean contains(@Nonnull Item item) { + public static boolean contains(@NonNull Item item) { ItemDeletion instance = instance(); if (instance == null) { return false; @@ -102,7 +102,7 @@ public static boolean contains(@Nonnull Item item) { * @return {@code true} if and only if the supplied {@link Item} has been {@linkplain #register(Item)}ed for * deletion. */ - public static boolean isRegistered(@Nonnull Item item) { + public static boolean isRegistered(@NonNull Item item) { ItemDeletion instance = instance(); if (instance == null) { return false; @@ -122,7 +122,7 @@ public static boolean isRegistered(@Nonnull Item item) { * @return {@code true} if and only if the {@link Item} was registered and the caller is now responsible to call * {@link #deregister(Item)}. */ - public static boolean register(@Nonnull Item item) { + public static boolean register(@NonNull Item item) { ItemDeletion instance = instance(); if (instance == null) { return false; @@ -140,7 +140,7 @@ public static boolean register(@Nonnull Item item) { * * @param item the {@link Item} that was to be deleted and is now either deleted or the delete was aborted. */ - public static void deregister(@Nonnull Item item) { + public static void deregister(@NonNull Item item) { ItemDeletion instance = instance(); if (instance != null) { instance.lock.writeLock().lock(); diff --git a/core/src/main/java/jenkins/mvn/GlobalMavenConfig.java b/core/src/main/java/jenkins/mvn/GlobalMavenConfig.java index 477aa34afd57..032d194b9324 100644 --- a/core/src/main/java/jenkins/mvn/GlobalMavenConfig.java +++ b/core/src/main/java/jenkins/mvn/GlobalMavenConfig.java @@ -8,7 +8,7 @@ import org.jenkinsci.Symbol; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; //as close as it gets to the global Maven Project configuration @Extension(ordinal = 50) @Symbol("maven") @@ -17,7 +17,7 @@ public class GlobalMavenConfig extends GlobalConfiguration implements Persisten private GlobalSettingsProvider globalSettingsProvider; @Override - public @Nonnull ToolConfigurationCategory getCategory() { + public @NonNull ToolConfigurationCategory getCategory() { return GlobalConfigurationCategory.get(ToolConfigurationCategory.class); } @@ -39,7 +39,7 @@ public SettingsProvider getSettingsProvider() { return settingsProvider != null ? settingsProvider : new DefaultSettingsProvider(); } - public static @Nonnull GlobalMavenConfig get() { + public static @NonNull GlobalMavenConfig get() { return GlobalConfiguration.all().getInstance(GlobalMavenConfig.class); } diff --git a/core/src/main/java/jenkins/plugins/DetachedPluginsUtil.java b/core/src/main/java/jenkins/plugins/DetachedPluginsUtil.java index be2dce8748ae..ec08e4b3e34f 100644 --- a/core/src/main/java/jenkins/plugins/DetachedPluginsUtil.java +++ b/core/src/main/java/jenkins/plugins/DetachedPluginsUtil.java @@ -11,7 +11,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; @@ -79,7 +79,7 @@ private DetachedPluginsUtil() { * * @since 2.0 */ - @Nonnull + @NonNull public static List getImpliedDependencies(String pluginName, String jenkinsVersion) { List out = new ArrayList<>(); for (DetachedPlugin detached : getDetachedPlugins()) { @@ -107,7 +107,7 @@ public static List getImpliedDependencies(String plugi * @return A {@link List} of {@link DetachedPlugin}s. * @see JavaUtils#getCurrentJavaRuntimeVersionNumber() */ - public static @Nonnull + public static @NonNull List getDetachedPlugins() { return DETACHED_LIST.stream() .filter(plugin -> JavaUtils.getCurrentJavaRuntimeVersionNumber().isNewerThanOrEqualTo(plugin.getMinimumJavaVersion())) @@ -121,8 +121,8 @@ List getDetachedPlugins() { * @return A {@link List} of {@link DetachedPlugin}s. * @see #getDetachedPlugins() */ - public static @Nonnull - List getDetachedPlugins(@Nonnull VersionNumber since) { + public static @NonNull + List getDetachedPlugins(@NonNull VersionNumber since) { return getDetachedPlugins().stream() .filter(detachedPlugin -> !detachedPlugin.getSplitWhen().isOlderThan(since)) .collect(Collectors.toList()); @@ -135,7 +135,7 @@ List getDetachedPlugins(@Nonnull VersionNumber since) { * @return {@code true} if the plugin is a plugin that was detached from Jenkins at some * point in the past, otherwise {@code false}. */ - public static boolean isDetachedPlugin(@Nonnull String pluginId) { + public static boolean isDetachedPlugin(@NonNull String pluginId) { for (DetachedPlugin detachedPlugin : getDetachedPlugins()) { if (detachedPlugin.getShortName().equals(pluginId)) { return true; @@ -217,7 +217,7 @@ public String toString() { return shortName + " " + splitWhen.toString().replace(".*", "") + " " + requiredVersion; } - @Nonnull + @NonNull public JavaSpecificationVersion getMinimumJavaVersion() { return minJavaVersion; } diff --git a/core/src/main/java/jenkins/scm/RunWithSCM.java b/core/src/main/java/jenkins/scm/RunWithSCM.java index 95e86a8cd3b3..528ecda039e2 100644 --- a/core/src/main/java/jenkins/scm/RunWithSCM.java +++ b/core/src/main/java/jenkins/scm/RunWithSCM.java @@ -34,8 +34,8 @@ import hudson.util.AdaptedIterator; import org.kohsuke.stapler.export.Exported; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.AbstractSet; import java.util.HashSet; import java.util.Iterator; @@ -57,7 +57,7 @@ public interface RunWithSCM, * * @return A possibly empty list of {@link ChangeLogSet}s. */ - @Nonnull + @NonNull List> getChangeSets(); /** @@ -90,7 +90,7 @@ public interface RunWithSCM, * can be empty but never null. */ @Exported - @Nonnull default Set getCulprits() { + @NonNull default Set getCulprits() { if (shouldCalculateCulprits()) { return calculateCulprits(); } @@ -120,7 +120,7 @@ public int size() { * @return a non-null {@link Set} of {@link User}s associated with this item. */ @SuppressWarnings("unchecked") - @Nonnull + @NonNull default Set calculateCulprits() { Set r = new HashSet<>(); RunT p = ((RunT)this).getPreviousCompletedBuild(); diff --git a/core/src/main/java/jenkins/scm/SCMDecisionHandler.java b/core/src/main/java/jenkins/scm/SCMDecisionHandler.java index cd6ba8fdb411..b21806009c5c 100644 --- a/core/src/main/java/jenkins/scm/SCMDecisionHandler.java +++ b/core/src/main/java/jenkins/scm/SCMDecisionHandler.java @@ -28,8 +28,8 @@ import hudson.model.Item; import java.util.ArrayList; import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Extension point for various decisions about SCM operations for {@link Item} instances. @@ -43,12 +43,12 @@ public abstract class SCMDecisionHandler implements ExtensionPoint { * * @param item The item. */ - public abstract boolean shouldPoll(@Nonnull Item item); + public abstract boolean shouldPoll(@NonNull Item item); /** * All registered {@link SCMDecisionHandler}s */ - @Nonnull + @NonNull public static ExtensionList all() { return ExtensionList.lookup(SCMDecisionHandler.class); } @@ -59,7 +59,7 @@ public static ExtensionList all() { * @return the first veto or {@code null} if there are no vetos */ @CheckForNull - public static SCMDecisionHandler firstShouldPollVeto(@Nonnull Item item) { + public static SCMDecisionHandler firstShouldPollVeto(@NonNull Item item) { for (SCMDecisionHandler handler : all()) { if (!handler.shouldPoll(item)) { return handler; @@ -73,8 +73,8 @@ public static SCMDecisionHandler firstShouldPollVeto(@Nonnull Item item) { * @param item the item * @return the {@link SCMDecisionHandler} instances vetoing the polling of the specified item. */ - @Nonnull - public static List listShouldPollVetos(@Nonnull Item item) { + @NonNull + public static List listShouldPollVetos(@NonNull Item item) { List result = new ArrayList<>(); for (SCMDecisionHandler handler : all()) { if (!handler.shouldPoll(item)) { diff --git a/core/src/main/java/jenkins/security/ApiTokenProperty.java b/core/src/main/java/jenkins/security/ApiTokenProperty.java index fb1afcfe3a36..090648f17dd9 100644 --- a/core/src/main/java/jenkins/security/ApiTokenProperty.java +++ b/core/src/main/java/jenkins/security/ApiTokenProperty.java @@ -60,9 +60,9 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.concurrent.Immutable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import net.jcip.annotations.Immutable; import org.apache.commons.lang.StringUtils; import org.kohsuke.accmod.Restricted; @@ -153,7 +153,7 @@ protected void setUser(User u) { * if the user has no appropriate permissions. * @since 1.426, and since 1.638 the method performs security checks */ - @Nonnull + @NonNull public String getApiToken() { LOGGER.log(Level.FINE, "Deprecated usage of getApiToken"); if(LOGGER.isLoggable(Level.FINER)){ @@ -172,7 +172,7 @@ public boolean hasLegacyToken(){ return apiToken != null; } - @Nonnull + @NonNull @Restricted(NoExternalUse.class) /*package*/ String getApiTokenInsecure() { if(apiToken == null){ @@ -251,7 +251,7 @@ public static class TokenInfoAndStats { public final Date lastUseDate; public final long numDaysUse; - public TokenInfoAndStats(@Nonnull ApiTokenStore.HashedToken token, @Nonnull ApiTokenStats.SingleTokenStats stats) { + public TokenInfoAndStats(@NonNull ApiTokenStore.HashedToken token, @NonNull ApiTokenStats.SingleTokenStats stats) { this.uuid = token.getUuid(); this.name = token.getName(); this.creationDate = token.getCreationDate(); diff --git a/core/src/main/java/jenkins/security/BasicApiTokenHelper.java b/core/src/main/java/jenkins/security/BasicApiTokenHelper.java index 5c73ba5f94c3..ddbd8536de5a 100644 --- a/core/src/main/java/jenkins/security/BasicApiTokenHelper.java +++ b/core/src/main/java/jenkins/security/BasicApiTokenHelper.java @@ -30,7 +30,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; diff --git a/core/src/main/java/jenkins/security/ChannelConfigurator.java b/core/src/main/java/jenkins/security/ChannelConfigurator.java index 87e0c33d0ca0..4ea8764f3bfa 100644 --- a/core/src/main/java/jenkins/security/ChannelConfigurator.java +++ b/core/src/main/java/jenkins/security/ChannelConfigurator.java @@ -6,7 +6,7 @@ import hudson.remoting.ChannelBuilder; import hudson.slaves.SlaveComputer; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; /** * Intercepts the new creation of {@link Channel} and tweak its configuration. diff --git a/core/src/main/java/jenkins/security/ClassFilterImpl.java b/core/src/main/java/jenkins/security/ClassFilterImpl.java index 98e2073c017c..62643b19cedb 100644 --- a/core/src/main/java/jenkins/security/ClassFilterImpl.java +++ b/core/src/main/java/jenkins/security/ClassFilterImpl.java @@ -51,8 +51,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import jenkins.util.SystemProperties; import org.apache.commons.io.IOUtils; @@ -264,7 +264,7 @@ private boolean isLocationWhitelisted(String _loc) { * @return something typically like {@code file:/…/plugins/structs/WEB-INF/lib/structs-1.10.jar}; * or null for classes in the Java Platform, some generated classes, etc. */ - private static @CheckForNull String codeSource(@Nonnull Class c) { + private static @CheckForNull String codeSource(@NonNull Class c) { CodeSource cs = c.getProtectionDomain().getCodeSource(); if (cs == null) { return null; diff --git a/core/src/main/java/jenkins/security/ConfidentialKey.java b/core/src/main/java/jenkins/security/ConfidentialKey.java index 8ef998a376c3..ccd7dc290f23 100644 --- a/core/src/main/java/jenkins/security/ConfidentialKey.java +++ b/core/src/main/java/jenkins/security/ConfidentialKey.java @@ -4,7 +4,7 @@ import hudson.tasks.Builder; import hudson.util.Secret; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.io.IOException; import jenkins.slaves.JnlpAgentReceiver; diff --git a/core/src/main/java/jenkins/security/ConfidentialStore.java b/core/src/main/java/jenkins/security/ConfidentialStore.java index 1062486e089f..b3194e0611d0 100644 --- a/core/src/main/java/jenkins/security/ConfidentialStore.java +++ b/core/src/main/java/jenkins/security/ConfidentialStore.java @@ -7,8 +7,8 @@ import jenkins.model.Jenkins; import org.kohsuke.MetaInfServices; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; @@ -68,7 +68,7 @@ public abstract class ConfidentialStore { /** * Retrieves the currently active singleton instance of {@link ConfidentialStore}. */ - public static @Nonnull ConfidentialStore get() { + public static @NonNull ConfidentialStore get() { if (TEST!=null) return TEST.get(); Jenkins j = Jenkins.getInstanceOrNull(); diff --git a/core/src/main/java/jenkins/security/CustomClassFilter.java b/core/src/main/java/jenkins/security/CustomClassFilter.java index 9fc4b28a3f70..4215e5845e9b 100644 --- a/core/src/main/java/jenkins/security/CustomClassFilter.java +++ b/core/src/main/java/jenkins/security/CustomClassFilter.java @@ -39,7 +39,7 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.model.Jenkins; import jenkins.util.SystemProperties; import org.apache.commons.io.IOUtils; diff --git a/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java b/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java index c8f98807102f..1ba8e92ef93a 100644 --- a/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java +++ b/core/src/main/java/jenkins/security/LastGrantedAuthoritiesProperty.java @@ -15,7 +15,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -69,7 +69,7 @@ public GrantedAuthority[] getAuthorities() { /** * Persist the information with the new {@link UserDetails}. */ - public void update(@Nonnull Authentication auth) throws IOException { + public void update(@NonNull Authentication auth) throws IOException { List roles = new ArrayList<>(); for (GrantedAuthority ga : auth.getAuthorities()) { roles.add(ga.getAuthority()); @@ -99,7 +99,7 @@ public void invalidate() throws IOException { @Extension public static class SecurityListenerImpl extends SecurityListener { @Override - protected void loggedIn(@Nonnull String username) { + protected void loggedIn(@NonNull String username) { try { // user should have been created but may not have been saved for some realms // but as this is a callback of a successful login we can safely create the user. @@ -116,7 +116,7 @@ protected void loggedIn(@Nonnull String username) { } @Override - protected void failedToLogIn(@Nonnull String username) { + protected void failedToLogIn(@NonNull String username) { // while this initially seemed like a good idea to avoid allowing wrong impersonation for too long, // doing this means a malicious user can break the impersonation capability // just by failing to login. See ApiTokenFilter that does the following, which seems better: diff --git a/core/src/main/java/jenkins/security/QueueItemAuthenticator.java b/core/src/main/java/jenkins/security/QueueItemAuthenticator.java index 40a243361bc7..f0deb015bb19 100644 --- a/core/src/main/java/jenkins/security/QueueItemAuthenticator.java +++ b/core/src/main/java/jenkins/security/QueueItemAuthenticator.java @@ -12,7 +12,7 @@ import hudson.model.queue.Tasks; import java.util.Calendar; import java.util.Collections; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import org.acegisecurity.Authentication; /** diff --git a/core/src/main/java/jenkins/security/QueueItemAuthenticatorConfiguration.java b/core/src/main/java/jenkins/security/QueueItemAuthenticatorConfiguration.java index b814cc61d5da..75c4cc85369a 100644 --- a/core/src/main/java/jenkins/security/QueueItemAuthenticatorConfiguration.java +++ b/core/src/main/java/jenkins/security/QueueItemAuthenticatorConfiguration.java @@ -10,7 +10,7 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.util.List; @@ -31,7 +31,7 @@ private Object readResolve() { } @Override - public @Nonnull GlobalConfigurationCategory getCategory() { + public @NonNull GlobalConfigurationCategory getCategory() { return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Security.class); } @@ -57,14 +57,14 @@ public boolean configure(StaplerRequest req, JSONObject json) throws FormExcepti } } - public static @Nonnull QueueItemAuthenticatorConfiguration get() { + public static @NonNull QueueItemAuthenticatorConfiguration get() { return GlobalConfiguration.all().getInstance(QueueItemAuthenticatorConfiguration.class); } @Extension(ordinal = 100) public static class ProviderImpl extends QueueItemAuthenticatorProvider { - @Nonnull + @NonNull @Override public List getAuthenticators() { return get().getAuthenticators(); diff --git a/core/src/main/java/jenkins/security/QueueItemAuthenticatorProvider.java b/core/src/main/java/jenkins/security/QueueItemAuthenticatorProvider.java index 98572c825dfd..4243406344f1 100644 --- a/core/src/main/java/jenkins/security/QueueItemAuthenticatorProvider.java +++ b/core/src/main/java/jenkins/security/QueueItemAuthenticatorProvider.java @@ -4,7 +4,7 @@ import hudson.ExtensionList; import hudson.ExtensionPoint; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -19,7 +19,7 @@ */ public abstract class QueueItemAuthenticatorProvider implements ExtensionPoint { - @Nonnull + @NonNull public abstract List getAuthenticators(); public static Iterable authenticators() { diff --git a/core/src/main/java/jenkins/security/ResourceDomainConfiguration.java b/core/src/main/java/jenkins/security/ResourceDomainConfiguration.java index 775b8dbf03c2..16f55502db9f 100644 --- a/core/src/main/java/jenkins/security/ResourceDomainConfiguration.java +++ b/core/src/main/java/jenkins/security/ResourceDomainConfiguration.java @@ -52,7 +52,7 @@ import java.security.interfaces.RSAPublicKey; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import static jenkins.security.ResourceDomainFilter.ERROR_RESPONSE; diff --git a/core/src/main/java/jenkins/security/ResourceDomainRootAction.java b/core/src/main/java/jenkins/security/ResourceDomainRootAction.java index 66aba7107ff2..700b0273d501 100644 --- a/core/src/main/java/jenkins/security/ResourceDomainRootAction.java +++ b/core/src/main/java/jenkins/security/ResourceDomainRootAction.java @@ -42,9 +42,9 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.*; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.Instant; @@ -143,7 +143,7 @@ public void doDynamic(StaplerRequest req, StaplerResponse rsp) throws IOExceptio } } - public String getRedirectUrl(@Nonnull Token token, @Nonnull String restOfPath) { + public String getRedirectUrl(@NonNull Token token, @NonNull String restOfPath) { String resourceRootUrl = getResourceRootUrl(); if (!restOfPath.startsWith("/")) { // Unsure whether this can happen -- just be safe here @@ -165,7 +165,7 @@ private static String getResourceRootUrl() { * @return a token that can be used to redirect users to the {@link ResourceDomainRootAction}. */ @CheckForNull - public Token getToken(@Nonnull DirectoryBrowserSupport dbs, @Nonnull StaplerRequest req) { + public Token getToken(@NonNull DirectoryBrowserSupport dbs, @NonNull StaplerRequest req) { // This is the "restOfPath" of the DirectoryBrowserSupport, i.e. the directory/file/pattern "inside" the DBS. final String dbsFile = req.getOriginalRestOfPath(); @@ -195,7 +195,7 @@ private static class InternalResourceRequest { private final String authenticationName; private final String browserUrl; - InternalResourceRequest(@Nonnull String browserUrl, @Nonnull String authenticationName) { + InternalResourceRequest(@NonNull String browserUrl, @NonNull String authenticationName) { this.browserUrl = browserUrl; this.authenticationName = authenticationName; } @@ -268,7 +268,7 @@ public static class Token { private Instant timestamp; @VisibleForTesting - Token (@Nonnull String path, @Nullable String username, @Nonnull Instant timestamp) { + Token (@NonNull String path, @Nullable String username, @NonNull Instant timestamp) { this.path = path; this.username = Util.fixNull(username); this.timestamp = timestamp; diff --git a/core/src/main/java/jenkins/security/SecurityListener.java b/core/src/main/java/jenkins/security/SecurityListener.java index 5ab4771904ec..d5256aade734 100644 --- a/core/src/main/java/jenkins/security/SecurityListener.java +++ b/core/src/main/java/jenkins/security/SecurityListener.java @@ -31,7 +31,7 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.acegisecurity.GrantedAuthority; import org.acegisecurity.userdetails.UserDetails; @@ -49,7 +49,7 @@ public abstract class SecurityListener implements ExtensionPoint { * or any other way plugins can propose. * @param details details of the newly authenticated user, such as name and groups. */ - protected void authenticated(@Nonnull UserDetails details){} + protected void authenticated(@NonNull UserDetails details){} /** * Fired when a user tried to authenticate but failed. @@ -58,7 +58,7 @@ protected void authenticated(@Nonnull UserDetails details){} * @param username the user * @see #authenticated */ - protected void failedToAuthenticate(@Nonnull String username){} + protected void failedToAuthenticate(@NonNull String username){} /** * Fired when a user has logged in. Compared to authenticated, there is a notion of storage / cache. @@ -66,7 +66,7 @@ protected void failedToAuthenticate(@Nonnull String username){} * It should be called after the {@link org.acegisecurity.context.SecurityContextHolder#getContext()}'s authentication is set. * @param username the user */ - protected void loggedIn(@Nonnull String username){} + protected void loggedIn(@NonNull String username){} /** * @since 2.161 @@ -75,23 +75,23 @@ protected void loggedIn(@Nonnull String username){} * * @param username the user */ - protected void userCreated(@Nonnull String username) {} + protected void userCreated(@NonNull String username) {} /** * Fired when a user has failed to log in. * Would be called after {@link #failedToAuthenticate}. * @param username the user */ - protected void failedToLogIn(@Nonnull String username){} + protected void failedToLogIn(@NonNull String username){} /** * Fired when a user logs out. * @param username the user */ - protected void loggedOut(@Nonnull String username){} + protected void loggedOut(@NonNull String username){} /** @since 1.569 */ - public static void fireAuthenticated(@Nonnull UserDetails details) { + public static void fireAuthenticated(@NonNull UserDetails details) { if (LOGGER.isLoggable(Level.FINE)) { List groups = new ArrayList<>(); for (GrantedAuthority auth : details.getAuthorities()) { @@ -107,7 +107,7 @@ public static void fireAuthenticated(@Nonnull UserDetails details) { } /** @since 2.161 */ - public static void fireUserCreated(@Nonnull String username) { + public static void fireUserCreated(@NonNull String username) { LOGGER.log(Level.FINE, "new user created: {0}", username); for (SecurityListener l : all()) { l.userCreated(username); @@ -115,7 +115,7 @@ public static void fireUserCreated(@Nonnull String username) { } /** @since 1.569 */ - public static void fireFailedToAuthenticate(@Nonnull String username) { + public static void fireFailedToAuthenticate(@NonNull String username) { LOGGER.log(Level.FINE, "failed to authenticate: {0}", username); for (SecurityListener l : all()) { l.failedToAuthenticate(username); @@ -123,7 +123,7 @@ public static void fireFailedToAuthenticate(@Nonnull String username) { } /** @since 1.569 */ - public static void fireLoggedIn(@Nonnull String username) { + public static void fireLoggedIn(@NonNull String username) { LOGGER.log(Level.FINE, "logged in: {0}", username); for (SecurityListener l : all()) { l.loggedIn(username); @@ -131,7 +131,7 @@ public static void fireLoggedIn(@Nonnull String username) { } /** @since 1.569 */ - public static void fireFailedToLogIn(@Nonnull String username) { + public static void fireFailedToLogIn(@NonNull String username) { LOGGER.log(Level.FINE, "failed to log in: {0}", username); for (SecurityListener l : all()) { l.failedToLogIn(username); @@ -139,7 +139,7 @@ public static void fireFailedToLogIn(@Nonnull String username) { } /** @since 1.569 */ - public static void fireLoggedOut(@Nonnull String username) { + public static void fireLoggedOut(@NonNull String username) { LOGGER.log(Level.FINE, "logged out: {0}", username); for (SecurityListener l : all()) { l.loggedOut(username); diff --git a/core/src/main/java/jenkins/security/UpdateSiteWarningsConfiguration.java b/core/src/main/java/jenkins/security/UpdateSiteWarningsConfiguration.java index a6237022582d..dc1aa0869164 100644 --- a/core/src/main/java/jenkins/security/UpdateSiteWarningsConfiguration.java +++ b/core/src/main/java/jenkins/security/UpdateSiteWarningsConfiguration.java @@ -36,8 +36,8 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.Collections; import java.util.HashSet; import java.util.Set; @@ -56,28 +56,28 @@ public class UpdateSiteWarningsConfiguration extends GlobalConfiguration impleme private HashSet ignoredWarnings = new HashSet<>(); @Override - public @Nonnull GlobalConfigurationCategory getCategory() { + public @NonNull GlobalConfigurationCategory getCategory() { return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Security.class); } - @Nonnull + @NonNull public Set getIgnoredWarnings() { return Collections.unmodifiableSet(ignoredWarnings); } - public boolean isIgnored(@Nonnull UpdateSite.Warning warning) { + public boolean isIgnored(@NonNull UpdateSite.Warning warning) { return ignoredWarnings.contains(warning.id); } @CheckForNull - public PluginWrapper getPlugin(@Nonnull UpdateSite.Warning warning) { + public PluginWrapper getPlugin(@NonNull UpdateSite.Warning warning) { if (warning.type != UpdateSite.Warning.Type.PLUGIN) { return null; } return Jenkins.get().getPluginManager().getPlugin(warning.component); } - @Nonnull + @NonNull public Set getAllWarnings() { HashSet allWarnings = new HashSet<>(); @@ -90,7 +90,7 @@ public Set getAllWarnings() { return allWarnings; } - @Nonnull + @NonNull public Set getApplicableWarnings() { Set allWarnings = getAllWarnings(); diff --git a/core/src/main/java/jenkins/security/UserDetailsCache.java b/core/src/main/java/jenkins/security/UserDetailsCache.java index 647052380049..653164efd420 100644 --- a/core/src/main/java/jenkins/security/UserDetailsCache.java +++ b/core/src/main/java/jenkins/security/UserDetailsCache.java @@ -36,8 +36,8 @@ import org.kohsuke.accmod.restrictions.NoExternalUse; import org.springframework.dao.DataAccessException; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.concurrent.Callable; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; @@ -117,7 +117,7 @@ public UserDetails getCached(String idOrFullName) throws UsernameNotFoundExcepti * @throws DataAccessException if user could not be found for a repository-specific reason * @throws ExecutionException if anything else went wrong in the cache lookup/retrieval */ - @Nonnull + @NonNull public UserDetails loadUserByUsername(String idOrFullName) throws UsernameNotFoundException, DataAccessException, ExecutionException { Boolean exists = existenceCache.getIfPresent(idOrFullName); if(exists != null && !exists) { diff --git a/core/src/main/java/jenkins/security/apitoken/ApiTokenStats.java b/core/src/main/java/jenkins/security/apitoken/ApiTokenStats.java index d63468217205..ef053b9943b0 100644 --- a/core/src/main/java/jenkins/security/apitoken/ApiTokenStats.java +++ b/core/src/main/java/jenkins/security/apitoken/ApiTokenStats.java @@ -33,8 +33,8 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.File; import java.io.IOException; import java.util.ArrayList; @@ -108,7 +108,7 @@ private void keepLastUpdatedUnique() { @Deprecated // to force even if someone wants to remove the one from the class @Restricted(NoExternalUse.class) - void setParent(@Nonnull File parent) { + void setParent(@NonNull File parent) { this.parent = parent; } @@ -119,7 +119,7 @@ private boolean areStatsDisabled(){ /** * Will trigger the save if there is some modification */ - public synchronized void removeId(@Nonnull String tokenUuid) { + public synchronized void removeId(@NonNull String tokenUuid) { if(areStatsDisabled()){ return; } @@ -133,7 +133,7 @@ public synchronized void removeId(@Nonnull String tokenUuid) { /** * Will trigger the save */ - public @Nonnull SingleTokenStats updateUsageForId(@Nonnull String tokenUuid) { + public @NonNull SingleTokenStats updateUsageForId(@NonNull String tokenUuid) { if(areStatsDisabled()){ return new SingleTokenStats(tokenUuid); } @@ -142,7 +142,7 @@ public synchronized void removeId(@Nonnull String tokenUuid) { } - private synchronized SingleTokenStats updateUsageForIdIfNeeded(@Nonnull String tokenUuid) { + private synchronized SingleTokenStats updateUsageForIdIfNeeded(@NonNull String tokenUuid) { SingleTokenStats stats = findById(tokenUuid) .orElseGet(() -> { SingleTokenStats result = new SingleTokenStats(tokenUuid); @@ -156,7 +156,7 @@ private synchronized SingleTokenStats updateUsageForIdIfNeeded(@Nonnull String t return stats; } - public synchronized @Nonnull SingleTokenStats findTokenStatsById(@Nonnull String tokenUuid) { + public synchronized @NonNull SingleTokenStats findTokenStatsById(@NonNull String tokenUuid) { if(areStatsDisabled()){ return new SingleTokenStats(tokenUuid); } @@ -166,7 +166,7 @@ private synchronized SingleTokenStats updateUsageForIdIfNeeded(@Nonnull String t .orElse(new SingleTokenStats(tokenUuid)); } - private @Nonnull Optional findById(@Nonnull String tokenUuid) { + private @NonNull Optional findById(@NonNull String tokenUuid) { return tokenStats.stream() .filter(s -> s.tokenUuid.equals(tokenUuid)) .findFirst(); @@ -228,7 +228,7 @@ public synchronized void save() { @Deprecated // to force even if someone wants to remove the one from the class @Restricted(NoExternalUse.class) - public static @Nonnull ApiTokenStats load(@CheckForNull File parent) { + public static @NonNull ApiTokenStats load(@CheckForNull File parent) { // even if we are not using statistics, we load the existing one in case the configuration // is enabled afterwards to avoid erasing data @@ -250,7 +250,7 @@ public synchronized void save() { *

* If the folder does not exist yet, a fresh new instance is created. */ - public static @Nonnull ApiTokenStats load(@Nonnull User user) { + public static @NonNull ApiTokenStats load(@NonNull User user) { // even if we are not using statistics, we load the existing one in case the configuration // is enabled afterwards to avoid erasing data @@ -271,7 +271,7 @@ public synchronized void save() { } @VisibleForTesting - static @CheckForNull ApiTokenStats internalLoad(@Nonnull File userFolder) { + static @CheckForNull ApiTokenStats internalLoad(@NonNull File userFolder) { ApiTokenStats apiTokenStats = null; XmlFile statsFile = getConfigFile(userFolder); if (statsFile.exists()) { @@ -286,7 +286,7 @@ public synchronized void save() { return apiTokenStats; } - protected static @Nonnull XmlFile getConfigFile(@Nonnull File parent) { + protected static @NonNull XmlFile getConfigFile(@NonNull File parent) { return new XmlFile(new File(parent, "apiTokenStats.xml")); } diff --git a/core/src/main/java/jenkins/security/apitoken/ApiTokenStore.java b/core/src/main/java/jenkins/security/apitoken/ApiTokenStore.java index 9fae97e9ff69..0e996f1324bb 100644 --- a/core/src/main/java/jenkins/security/apitoken/ApiTokenStore.java +++ b/core/src/main/java/jenkins/security/apitoken/ApiTokenStore.java @@ -32,10 +32,10 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; +import net.jcip.annotations.Immutable; import java.io.Serializable; import java.nio.charset.StandardCharsets; import java.security.MessageDigest; @@ -87,7 +87,7 @@ private void init() { } @SuppressFBWarnings("NP_NONNULL_RETURN_VIOLATION") - public synchronized @Nonnull Collection getTokenListSortedByName() { + public synchronized @NonNull Collection getTokenListSortedByName() { return tokenList.stream() .sorted(SORT_BY_LOWERCASED_NAME) .collect(Collectors.toList()); @@ -101,7 +101,7 @@ private void addToken(HashedToken token) { * Defensive approach to avoid involuntary change since the UUIDs are generated at startup only for UI * and so between restart they change */ - public synchronized void reconfigure(@Nonnull Map tokenStoreDataMap) { + public synchronized void reconfigure(@NonNull Map tokenStoreDataMap) { tokenList.forEach(hashedToken -> { JSONObject receivedTokenData = tokenStoreDataMap.get(hashedToken.uuid); if (receivedTokenData == null) { @@ -122,7 +122,7 @@ public synchronized void reconfigure(@Nonnull Map tokenStore /** * Remove the legacy token present and generate a new one using the given secret. */ - public synchronized void regenerateTokenFromLegacy(@Nonnull Secret newLegacyApiToken) { + public synchronized void regenerateTokenFromLegacy(@NonNull Secret newLegacyApiToken) { deleteAllLegacyAndGenerateNewOne(newLegacyApiToken, false); } @@ -131,13 +131,13 @@ public synchronized void regenerateTokenFromLegacy(@Nonnull Secret newLegacyApiT *

* Otherwise, no effect. */ - public synchronized void regenerateTokenFromLegacyIfRequired(@Nonnull Secret newLegacyApiToken) { + public synchronized void regenerateTokenFromLegacyIfRequired(@NonNull Secret newLegacyApiToken) { if(tokenList.stream().noneMatch(HashedToken::isLegacy)){ deleteAllLegacyAndGenerateNewOne(newLegacyApiToken, true); } } - private void deleteAllLegacyAndGenerateNewOne(@Nonnull Secret newLegacyApiToken, boolean migrationFromExistingLegacy) { + private void deleteAllLegacyAndGenerateNewOne(@NonNull Secret newLegacyApiToken, boolean migrationFromExistingLegacy) { deleteAllLegacyTokens(); addLegacyToken(newLegacyApiToken, migrationFromExistingLegacy); } @@ -147,7 +147,7 @@ private void deleteAllLegacyTokens() { tokenList.removeIf(HashedToken::isLegacy); } - private void addLegacyToken(@Nonnull Secret legacyToken, boolean migrationFromExistingLegacy) { + private void addLegacyToken(@NonNull Secret legacyToken, boolean migrationFromExistingLegacy) { String tokenUserUseNormally = Util.getDigestOf(legacyToken.getPlainText()); String secretValueHashed = this.plainSecretToHashInHex(tokenUserUseNormally); @@ -172,7 +172,7 @@ private void addLegacyToken(@Nonnull Secret legacyToken, boolean migrationFromEx * Create a new token with the given name and return it id and secret value. * Result meant to be sent / displayed and then discarded. */ - public synchronized @Nonnull TokenUuidAndPlainValue generateNewToken(@Nonnull String name) { + public synchronized @NonNull TokenUuidAndPlainValue generateNewToken(@NonNull String name) { // 16x8=128bit worth of randomness, using brute-force you need on average 2^127 tries (~10^37) byte[] random = new byte[16]; RANDOM.nextBytes(random); @@ -190,17 +190,17 @@ private void addLegacyToken(@Nonnull Secret legacyToken, boolean migrationFromEx return new TokenUuidAndPlainValue(token.uuid, tokenTheUserWillUse); } - private @Nonnull String plainSecretToHashInHex(@Nonnull String secretValueInPlainText) { + private @NonNull String plainSecretToHashInHex(@NonNull String secretValueInPlainText) { byte[] hashBytes = plainSecretToHashBytes(secretValueInPlainText); return Util.toHexString(hashBytes); } - private @Nonnull byte[] plainSecretToHashBytes(@Nonnull String secretValueInPlainText) { + private @NonNull byte[] plainSecretToHashBytes(@NonNull String secretValueInPlainText) { // ascii is sufficient for hex-format return hashedBytes(secretValueInPlainText.getBytes(StandardCharsets.US_ASCII)); } - private @Nonnull byte[] hashedBytes(byte[] tokenBytes) { + private @NonNull byte[] hashedBytes(byte[] tokenBytes) { MessageDigest digest; try { digest = MessageDigest.getInstance(HASH_ALGORITHM); @@ -214,7 +214,7 @@ private void addLegacyToken(@Nonnull Secret legacyToken, boolean migrationFromEx * Search in the store if there is a token with the same secret as the one given * @return {@code null} iff there is no matching token */ - public synchronized @CheckForNull HashedToken findMatchingToken(@Nonnull String token) { + public synchronized @CheckForNull HashedToken findMatchingToken(@NonNull String token) { String plainToken; if (isLegacyToken(token)) { plainToken = token; @@ -228,7 +228,7 @@ private void addLegacyToken(@Nonnull Secret legacyToken, boolean migrationFromEx /** * Determine if the given token was generated by the legacy system or the new one */ - private boolean isLegacyToken(@Nonnull String token) { + private boolean isLegacyToken(@NonNull String token) { return token.length() != TOKEN_LENGTH_V2; } @@ -237,7 +237,7 @@ private boolean isLegacyToken(@Nonnull String token) { * @param token assumed the token is not a legacy one and represent the full token (version + hash) * @return the hash part */ - private @Nonnull String getHashOfToken(@Nonnull String token) { + private @NonNull String getHashOfToken(@NonNull String token) { /* * Structure of the token: * @@ -251,7 +251,7 @@ private boolean isLegacyToken(@Nonnull String token) { * Search in the store if there is a matching token that has the same secret. * @return {@code null} iff there is no matching token */ - private @CheckForNull HashedToken searchMatch(@Nonnull String plainSecret) { + private @CheckForNull HashedToken searchMatch(@NonNull String plainSecret) { byte[] hashedBytes = plainSecretToHashBytes(plainSecret); for (HashedToken token : tokenList) { if (token.match(hashedBytes)) { @@ -268,7 +268,7 @@ private boolean isLegacyToken(@Nonnull String token) { * @param tokenUuid The identifier of the token, could be retrieved directly from the {@link HashedToken#getUuid()} * @return the revoked token corresponding to the given {@code tokenUuid} if one was found, otherwise {@code null} */ - public synchronized @CheckForNull HashedToken revokeToken(@Nonnull String tokenUuid) { + public synchronized @CheckForNull HashedToken revokeToken(@NonNull String tokenUuid) { for (Iterator iterator = tokenList.iterator(); iterator.hasNext(); ) { HashedToken token = iterator.next(); if (token.uuid.equals(tokenUuid)) { @@ -285,7 +285,7 @@ private boolean isLegacyToken(@Nonnull String token) { * Given a token identifier and a name, the system will try to find a corresponding token and rename it * @return {@code true} iff the token was found and the rename was successful */ - public synchronized boolean renameToken(@Nonnull String tokenUuid, @Nonnull String newName) { + public synchronized boolean renameToken(@NonNull String tokenUuid, @NonNull String newName) { for (HashedToken token : tokenList) { if (token.uuid.equals(tokenUuid)) { token.rename(newName); @@ -366,7 +366,7 @@ private void init() { } } - public static @Nonnull HashedToken buildNew(@Nonnull String name, @Nonnull HashValue value) { + public static @NonNull HashedToken buildNew(@NonNull String name, @NonNull HashValue value) { HashedToken result = new HashedToken(); result.name = name; result.creationDate = new Date(); @@ -376,7 +376,7 @@ private void init() { return result; } - public static @Nonnull HashedToken buildNewFromLegacy(@Nonnull HashValue value, boolean migrationFromExistingLegacy) { + public static @NonNull HashedToken buildNewFromLegacy(@NonNull HashValue value, boolean migrationFromExistingLegacy) { HashedToken result = new HashedToken(); result.name = Messages.ApiTokenProperty_LegacyTokenName(); if(migrationFromExistingLegacy){ diff --git a/core/src/main/java/jenkins/security/apitoken/LegacyApiTokenAdministrativeMonitor.java b/core/src/main/java/jenkins/security/apitoken/LegacyApiTokenAdministrativeMonitor.java index dd64894006d7..3320ccb6efa5 100644 --- a/core/src/main/java/jenkins/security/apitoken/LegacyApiTokenAdministrativeMonitor.java +++ b/core/src/main/java/jenkins/security/apitoken/LegacyApiTokenAdministrativeMonitor.java @@ -36,8 +36,8 @@ import org.kohsuke.stapler.interceptor.RequirePOST; import org.kohsuke.stapler.json.JsonBody; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import java.io.IOException; import java.util.Date; import java.util.List; @@ -89,14 +89,14 @@ public List getImpactedUserList() { // used by Jelly view @Restricted(NoExternalUse.class) - public @Nullable ApiTokenStore.HashedToken getLegacyTokenOf(@Nonnull User user) { + public @Nullable ApiTokenStore.HashedToken getLegacyTokenOf(@NonNull User user) { ApiTokenProperty apiTokenProperty = user.getProperty(ApiTokenProperty.class); return apiTokenProperty.getTokenStore().getLegacyToken(); } // used by Jelly view @Restricted(NoExternalUse.class) - public @Nullable ApiTokenProperty.TokenInfoAndStats getLegacyStatsOf(@Nonnull User user, ApiTokenStore.HashedToken legacyToken) { + public @Nullable ApiTokenProperty.TokenInfoAndStats getLegacyStatsOf(@NonNull User user, ApiTokenStore.HashedToken legacyToken) { ApiTokenProperty apiTokenProperty = user.getProperty(ApiTokenProperty.class); if (legacyToken != null) { ApiTokenStats.SingleTokenStats legacyStats = apiTokenProperty.getTokenStats().findTokenStatsById(legacyToken.getUuid()); @@ -112,7 +112,7 @@ public List getImpactedUserList() { */ // used by Jelly view @Restricted(NoExternalUse.class) - public boolean hasFreshToken(@Nonnull User user, ApiTokenProperty.TokenInfoAndStats legacyStats) { + public boolean hasFreshToken(@NonNull User user, ApiTokenProperty.TokenInfoAndStats legacyStats) { if (legacyStats == null) { return false; } @@ -136,7 +136,7 @@ public boolean hasFreshToken(@Nonnull User user, ApiTokenProperty.TokenInfoAndSt */ // used by Jelly view @Restricted(NoExternalUse.class) - public boolean hasMoreRecentlyUsedToken(@Nonnull User user, ApiTokenProperty.TokenInfoAndStats legacyStats) { + public boolean hasMoreRecentlyUsedToken(@NonNull User user, ApiTokenProperty.TokenInfoAndStats legacyStats) { if (legacyStats == null) { return false; } diff --git a/core/src/main/java/jenkins/security/s2m/AdminFilePathFilter.java b/core/src/main/java/jenkins/security/s2m/AdminFilePathFilter.java index d5d94b52d5d7..0982a15fc4de 100644 --- a/core/src/main/java/jenkins/security/s2m/AdminFilePathFilter.java +++ b/core/src/main/java/jenkins/security/s2m/AdminFilePathFilter.java @@ -6,7 +6,7 @@ import jenkins.ReflectiveFilePathFilter; import jenkins.security.ChannelConfigurator; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; import javax.inject.Inject; import java.io.File; diff --git a/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java b/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java index 5ee224e30ed6..2bcebf535891 100644 --- a/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java +++ b/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java @@ -16,8 +16,8 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.CheckReturnValue; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckReturnValue; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.BufferedReader; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -94,7 +94,7 @@ public AdminWhitelistRule() throws IOException, InterruptedException { * @return {@code true} if the file was loaded, {@code false} otherwise */ @CheckReturnValue - private boolean loadMasterKillSwitchFile(@Nonnull File f) { + private boolean loadMasterKillSwitchFile(@NonNull File f) { try { if (!f.exists()) return true; return Boolean.parseBoolean(FileUtils.readFileToString(f, Charset.defaultCharset()).trim()); @@ -104,8 +104,8 @@ private boolean loadMasterKillSwitchFile(@Nonnull File f) { } } - @Nonnull - private File getMasterKillSwitchFile(@Nonnull Jenkins jenkins) { + @NonNull + private File getMasterKillSwitchFile(@NonNull Jenkins jenkins) { return new File(jenkins.getRootDir(),"secrets/slave-to-master-security-kill-switch"); } diff --git a/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java b/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java index 194e83c81397..76ae2ecd2a13 100644 --- a/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java +++ b/core/src/main/java/jenkins/security/s2m/CallableDirectionChecker.java @@ -13,7 +13,7 @@ import org.kohsuke.accmod.restrictions.DoNotUse; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.Collection; import java.util.logging.Level; import java.util.logging.Logger; @@ -46,7 +46,7 @@ private CallableDirectionChecker(Object context) { } @Override - public void check(RoleSensitive subject, @Nonnull Collection expected) throws SecurityException { + public void check(RoleSensitive subject, @NonNull Collection expected) throws SecurityException { final String name = subject.getClass().getName(); if (expected.contains(Roles.MASTER)) { diff --git a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java index f531b31f8ac0..96322cafbbc8 100644 --- a/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java +++ b/core/src/main/java/jenkins/security/s2m/MasterKillSwitchConfiguration.java @@ -2,7 +2,7 @@ import hudson.Extension; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.inject.Inject; import jenkins.model.GlobalConfiguration; import jenkins.model.GlobalConfigurationCategory; @@ -25,7 +25,7 @@ public class MasterKillSwitchConfiguration extends GlobalConfiguration { Jenkins jenkins; @Override - public @Nonnull GlobalConfigurationCategory getCategory() { + public @NonNull GlobalConfigurationCategory getCategory() { return GlobalConfigurationCategory.get(GlobalConfigurationCategory.Security.class); } diff --git a/core/src/main/java/jenkins/security/s2m/RejectedCallable.java b/core/src/main/java/jenkins/security/s2m/RejectedCallable.java index 5c50dbaeb380..a0242c532984 100644 --- a/core/src/main/java/jenkins/security/s2m/RejectedCallable.java +++ b/core/src/main/java/jenkins/security/s2m/RejectedCallable.java @@ -3,7 +3,7 @@ import hudson.PluginWrapper; import jenkins.model.Jenkins; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * @author Kohsuke Kawaguchi diff --git a/core/src/main/java/jenkins/security/seed/UserSeedChangeListener.java b/core/src/main/java/jenkins/security/seed/UserSeedChangeListener.java index d8f91739522f..2f777a573b43 100644 --- a/core/src/main/java/jenkins/security/seed/UserSeedChangeListener.java +++ b/core/src/main/java/jenkins/security/seed/UserSeedChangeListener.java @@ -30,7 +30,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -47,13 +47,13 @@ public abstract class UserSeedChangeListener extends ExtensionPoint { * Called after a seed was changed but before the user is saved. * @param user The target user */ - public abstract void onUserSeedRenewed(@Nonnull User user); + public abstract void onUserSeedRenewed(@NonNull User user); /** * Will notify all the registered listeners about the event * @param user The target user */ - public static void fireUserSeedRenewed(@Nonnull User user) { + public static void fireUserSeedRenewed(@NonNull User user) { for (UserSeedChangeListener l : all()) { try { l.onUserSeedRenewed(user); diff --git a/core/src/main/java/jenkins/security/seed/UserSeedProperty.java b/core/src/main/java/jenkins/security/seed/UserSeedProperty.java index afd3d5e6653a..0d7919876cea 100644 --- a/core/src/main/java/jenkins/security/seed/UserSeedProperty.java +++ b/core/src/main/java/jenkins/security/seed/UserSeedProperty.java @@ -41,7 +41,7 @@ import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.security.SecureRandom; import java.util.Objects; @@ -83,7 +83,7 @@ private UserSeedProperty() { this.renewSeedInternal(); } - public @Nonnull String getSeed() { + public @NonNull String getSeed() { return seed; } @@ -107,7 +107,7 @@ private void renewSeedInternal() { @Extension @Symbol("userSeed") public static final class DescriptorImpl extends UserPropertyDescriptor { - public @Nonnull String getDisplayName() { + public @NonNull String getDisplayName() { return Messages.UserSeedProperty_DisplayName(); } @@ -117,12 +117,12 @@ public UserSeedProperty newInstance(User user) { // only for jelly @Restricted(DoNotUse.class) - public boolean isCurrentUser(@Nonnull User target) { + public boolean isCurrentUser(@NonNull User target) { return Objects.equals(User.current(), target); } @RequirePOST - public synchronized HttpResponse doRenewSessionSeed(@AncestorInPath @Nonnull User u) throws IOException { + public synchronized HttpResponse doRenewSessionSeed(@AncestorInPath @NonNull User u) throws IOException { u.checkPermission(Jenkins.ADMINISTER); if (DISABLE_USER_SEED) { diff --git a/core/src/main/java/jenkins/security/seed/UserSeedSecurityListener.java b/core/src/main/java/jenkins/security/seed/UserSeedSecurityListener.java index f87449341a20..754700e62b14 100644 --- a/core/src/main/java/jenkins/security/seed/UserSeedSecurityListener.java +++ b/core/src/main/java/jenkins/security/seed/UserSeedSecurityListener.java @@ -32,7 +32,7 @@ import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.http.HttpSession; /** @@ -43,12 +43,12 @@ @Extension(ordinal = Integer.MAX_VALUE) public class UserSeedSecurityListener extends SecurityListener { @Override - protected void loggedIn(@Nonnull String username) { + protected void loggedIn(@NonNull String username) { putUserSeedInSession(username, true); } @Override - protected void authenticated(@Nonnull UserDetails details) { + protected void authenticated(@NonNull UserDetails details) { putUserSeedInSession(details.getUsername(), false); } diff --git a/core/src/main/java/jenkins/security/stapler/DoActionFilter.java b/core/src/main/java/jenkins/security/stapler/DoActionFilter.java index 9719625826ef..d65e0fca26cd 100644 --- a/core/src/main/java/jenkins/security/stapler/DoActionFilter.java +++ b/core/src/main/java/jenkins/security/stapler/DoActionFilter.java @@ -31,7 +31,7 @@ import org.kohsuke.stapler.HttpResponse; import org.kohsuke.stapler.interceptor.InterceptorAnnotation; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.lang.annotation.Annotation; import java.util.logging.Level; import java.util.logging.Logger; @@ -49,7 +49,7 @@ public class DoActionFilter implements FunctionList.Filter { */ private static final Pattern DO_METHOD_REGEX = Pattern.compile("^do[^a-z].*"); - public boolean keep(@Nonnull Function m) { + public boolean keep(@NonNull Function m) { if (m.getAnnotation(StaplerNotDispatchable.class) != null) { return false; diff --git a/core/src/main/java/jenkins/security/stapler/RoutingDecisionProvider.java b/core/src/main/java/jenkins/security/stapler/RoutingDecisionProvider.java index c7cab91839b7..917b5d32b768 100644 --- a/core/src/main/java/jenkins/security/stapler/RoutingDecisionProvider.java +++ b/core/src/main/java/jenkins/security/stapler/RoutingDecisionProvider.java @@ -25,7 +25,7 @@ import hudson.ExtensionPoint; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; public abstract class RoutingDecisionProvider implements ExtensionPoint { enum Decision { @@ -34,5 +34,5 @@ enum Decision { UNKNOWN } - @Nonnull public abstract Decision decide(@Nonnull String signature); + @NonNull public abstract Decision decide(@NonNull String signature); } diff --git a/core/src/main/java/jenkins/security/stapler/StaplerDispatchValidator.java b/core/src/main/java/jenkins/security/stapler/StaplerDispatchValidator.java index 163258c23b4d..d67ca6c038fa 100644 --- a/core/src/main/java/jenkins/security/stapler/StaplerDispatchValidator.java +++ b/core/src/main/java/jenkins/security/stapler/StaplerDispatchValidator.java @@ -36,8 +36,8 @@ import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.WebApp; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletContext; import java.io.IOException; import java.io.InputStream; @@ -92,7 +92,7 @@ public class StaplerDispatchValidator implements DispatchValidator { */ public static /* script-console editable */ boolean DISABLED = SystemProperties.getBoolean(ESCAPE_HATCH); - private static @CheckForNull Boolean setStatus(@Nonnull StaplerRequest req, @CheckForNull Boolean status) { + private static @CheckForNull Boolean setStatus(@NonNull StaplerRequest req, @CheckForNull Boolean status) { if (status == null) { return null; } @@ -101,7 +101,7 @@ public class StaplerDispatchValidator implements DispatchValidator { return status; } - private static @CheckForNull Boolean computeStatusIfNull(@Nonnull StaplerRequest req, @Nonnull Supplier statusIfNull) { + private static @CheckForNull Boolean computeStatusIfNull(@NonNull StaplerRequest req, @NonNull Supplier statusIfNull) { Object requestStatus = req.getAttribute(ATTRIBUTE_NAME); return requestStatus instanceof Boolean ? (Boolean) requestStatus : setStatus(req, statusIfNull.get()); } @@ -114,7 +114,7 @@ public StaplerDispatchValidator() { } @Override - public @CheckForNull Boolean isDispatchAllowed(@Nonnull StaplerRequest req, @Nonnull StaplerResponse rsp) { + public @CheckForNull Boolean isDispatchAllowed(@NonNull StaplerRequest req, @NonNull StaplerResponse rsp) { if (DISABLED) { return true; } @@ -132,7 +132,7 @@ public StaplerDispatchValidator() { } @Override - public @CheckForNull Boolean isDispatchAllowed(@Nonnull StaplerRequest req, @Nonnull StaplerResponse rsp, @Nonnull String viewName, @CheckForNull Object node) { + public @CheckForNull Boolean isDispatchAllowed(@NonNull StaplerRequest req, @NonNull StaplerResponse rsp, @NonNull String viewName, @CheckForNull Object node) { if (DISABLED) { return true; } @@ -150,7 +150,7 @@ public StaplerDispatchValidator() { } @Override - public void allowDispatch(@Nonnull StaplerRequest req, @Nonnull StaplerResponse rsp) { + public void allowDispatch(@NonNull StaplerRequest req, @NonNull StaplerResponse rsp) { if (DISABLED) { return; } @@ -158,7 +158,7 @@ public void allowDispatch(@Nonnull StaplerRequest req, @Nonnull StaplerResponse } @Override - public void requireDispatchAllowed(@Nonnull StaplerRequest req, @Nonnull StaplerResponse rsp) throws CancelRequestHandlingException { + public void requireDispatchAllowed(@NonNull StaplerRequest req, @NonNull StaplerResponse rsp) throws CancelRequestHandlingException { if (DISABLED) { return; } @@ -170,12 +170,12 @@ public void requireDispatchAllowed(@Nonnull StaplerRequest req, @Nonnull Stapler } @VisibleForTesting - static StaplerDispatchValidator getInstance(@Nonnull ServletContext context) { + static StaplerDispatchValidator getInstance(@NonNull ServletContext context) { return (StaplerDispatchValidator) WebApp.get(context).getDispatchValidator(); } @VisibleForTesting - void loadWhitelist(@Nonnull InputStream in) throws IOException { + void loadWhitelist(@NonNull InputStream in) throws IOException { cache.loadWhitelist(IOUtils.readLines(in)); } @@ -185,7 +185,7 @@ private static class ValidatorCache { // provided as alternative to ConcurrentHashMap.computeIfAbsent which doesn't allow for recursion in the supplier // see https://stackoverflow.com/q/28840047 - private @Nonnull Validator computeIfAbsent(@Nonnull String className, @Nonnull Function constructor) { + private @NonNull Validator computeIfAbsent(@NonNull String className, @NonNull Function constructor) { lock.readLock().lock(); try { if (validators.containsKey(className)) { @@ -209,15 +209,15 @@ private static class ValidatorCache { } } - private @Nonnull Validator find(@Nonnull Class clazz) { + private @NonNull Validator find(@NonNull Class clazz) { return computeIfAbsent(clazz.getName(), name -> create(clazz)); } - private @Nonnull Validator find(@Nonnull String className) { + private @NonNull Validator find(@NonNull String className) { return computeIfAbsent(className, this::create); } - private @Nonnull Collection findParents(@Nonnull Class clazz) { + private @NonNull Collection findParents(@NonNull Class clazz) { List parents = new ArrayList<>(); Class superclass = clazz.getSuperclass(); if (superclass != null) { @@ -229,7 +229,7 @@ private static class ValidatorCache { return parents; } - private @Nonnull Validator create(@Nonnull Class clazz) { + private @NonNull Validator create(@NonNull Class clazz) { Set allowed = new HashSet<>(); StaplerViews views = clazz.getDeclaredAnnotation(StaplerViews.class); if (views != null) { @@ -243,7 +243,7 @@ private static class ValidatorCache { return new Validator(() -> findParents(clazz), allowed, denied); } - private @Nonnull Validator create(@Nonnull String className) { + private @NonNull Validator create(@NonNull String className) { ClassLoader loader = Jenkins.get().pluginManager.uberClassLoader; return new Validator(() -> { try { @@ -274,7 +274,7 @@ private void load() { } } - private void loadWhitelist(@Nonnull List whitelistLines) { + private void loadWhitelist(@NonNull List whitelistLines) { for (String line : whitelistLines) { if (line.matches("#.*|\\s*")) { // commented line @@ -305,17 +305,17 @@ private class Validator { private final Set allowed = ConcurrentHashMap.newKeySet(); private final Set denied = ConcurrentHashMap.newKeySet(); - private Validator(@Nonnull Supplier> parentsSupplier) { + private Validator(@NonNull Supplier> parentsSupplier) { this.parentsSupplier = parentsSupplier; } - private Validator(@Nonnull Supplier> parentsSupplier, @Nonnull Collection allowed, @Nonnull Collection denied) { + private Validator(@NonNull Supplier> parentsSupplier, @NonNull Collection allowed, @NonNull Collection denied) { this(parentsSupplier); this.allowed.addAll(allowed); this.denied.addAll(denied); } - private @Nonnull Collection getParents() { + private @NonNull Collection getParents() { if (parents == null) { synchronized (this) { if (parents == null) { @@ -326,7 +326,7 @@ private Validator(@Nonnull Supplier> parentsSupplier, @Non return parents; } - private @CheckForNull Boolean isViewValid(@Nonnull String viewName) { + private @CheckForNull Boolean isViewValid(@NonNull String viewName) { if (allowed.contains(viewName)) { return Boolean.TRUE; } @@ -342,11 +342,11 @@ private Validator(@Nonnull Supplier> parentsSupplier, @Non return null; } - private void allowView(@Nonnull String viewName) { + private void allowView(@NonNull String viewName) { allowed.add(viewName); } - private void denyView(@Nonnull String viewName) { + private void denyView(@NonNull String viewName) { denied.add(viewName); } } diff --git a/core/src/main/java/jenkins/security/stapler/StaticRoutingDecisionProvider.java b/core/src/main/java/jenkins/security/stapler/StaticRoutingDecisionProvider.java index cbb587601540..2b63657e80c6 100644 --- a/core/src/main/java/jenkins/security/stapler/StaticRoutingDecisionProvider.java +++ b/core/src/main/java/jenkins/security/stapler/StaticRoutingDecisionProvider.java @@ -38,7 +38,7 @@ import org.kohsuke.stapler.WebApp; import org.kohsuke.stapler.lang.FieldRef; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -80,8 +80,8 @@ public static StaticRoutingDecisionProvider get() { * @see Function#getSignature() * @see FieldRef#getSignature() */ - @Nonnull - public synchronized Decision decide(@Nonnull String signature) { + @NonNull + public synchronized Decision decide(@NonNull String signature) { if (whitelistSignaturesFromFixedList == null || whitelistSignaturesFromUserControlledList == null || blacklistSignaturesFromFixedList == null || blacklistSignaturesFromUserControlledList == null) { reload(); @@ -140,7 +140,7 @@ private synchronized void reloadFromDefault() { LOGGER.log(Level.FINE, "Found {0} getter in the standard whitelist", whitelistSignaturesFromFixedList.size()); } - public synchronized StaticRoutingDecisionProvider add(@Nonnull String signature) { + public synchronized StaticRoutingDecisionProvider add(@NonNull String signature) { if (this.whitelistSignaturesFromUserControlledList.add(signature)) { LOGGER.log(Level.INFO, "Signature [{0}] added to the whitelist", signature); save(); @@ -151,7 +151,7 @@ public synchronized StaticRoutingDecisionProvider add(@Nonnull String signature) return this; } - public synchronized StaticRoutingDecisionProvider addBlacklistSignature(@Nonnull String signature) { + public synchronized StaticRoutingDecisionProvider addBlacklistSignature(@NonNull String signature) { if (this.blacklistSignaturesFromUserControlledList.add(signature)) { LOGGER.log(Level.INFO, "Signature [{0}] added to the blacklist", signature); save(); @@ -162,7 +162,7 @@ public synchronized StaticRoutingDecisionProvider addBlacklistSignature(@Nonnull return this; } - public synchronized StaticRoutingDecisionProvider remove(@Nonnull String signature) { + public synchronized StaticRoutingDecisionProvider remove(@NonNull String signature) { if (this.whitelistSignaturesFromUserControlledList.remove(signature)) { LOGGER.log(Level.INFO, "Signature [{0}] removed from the whitelist", signature); save(); @@ -173,7 +173,7 @@ public synchronized StaticRoutingDecisionProvider remove(@Nonnull String signatu return this; } - public synchronized StaticRoutingDecisionProvider removeBlacklistSignature(@Nonnull String signature) { + public synchronized StaticRoutingDecisionProvider removeBlacklistSignature(@NonNull String signature) { if (this.blacklistSignaturesFromUserControlledList.remove(signature)) { LOGGER.log(Level.INFO, "Signature [{0}] removed from the blacklist", signature); save(); diff --git a/core/src/main/java/jenkins/security/stapler/TypedFilter.java b/core/src/main/java/jenkins/security/stapler/TypedFilter.java index 6f9bdb4019d8..e95ba84f8ba5 100644 --- a/core/src/main/java/jenkins/security/stapler/TypedFilter.java +++ b/core/src/main/java/jenkins/security/stapler/TypedFilter.java @@ -13,7 +13,7 @@ import org.kohsuke.stapler.interceptor.InterceptorAnnotation; import org.kohsuke.stapler.lang.FieldRef; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.HashMap; @@ -49,7 +49,7 @@ private boolean isClassAcceptable(Class clazz) { return SKIP_TYPE_CHECK || isStaplerRelevantCached(clazz); } - private static boolean isStaplerRelevantCached(@Nonnull Class clazz) { + private static boolean isStaplerRelevantCached(@NonNull Class clazz) { if (staplerCache.containsKey(clazz)) { return staplerCache.get(clazz); } @@ -60,11 +60,11 @@ private static boolean isStaplerRelevantCached(@Nonnull Class clazz) { } @Restricted(NoExternalUse.class) - public static boolean isStaplerRelevant(@Nonnull Class clazz) { + public static boolean isStaplerRelevant(@NonNull Class clazz) { return isSpecificClassStaplerRelevant(clazz) || isSuperTypesStaplerRelevant(clazz); } - private static boolean isSuperTypesStaplerRelevant(@Nonnull Class clazz) { + private static boolean isSuperTypesStaplerRelevant(@NonNull Class clazz) { Class superclass = clazz.getSuperclass(); if (superclass != null && isStaplerRelevantCached(superclass)) { return true; @@ -77,7 +77,7 @@ private static boolean isSuperTypesStaplerRelevant(@Nonnull Class clazz) { return false; } - private static boolean isSpecificClassStaplerRelevant(@Nonnull Class clazz) { + private static boolean isSpecificClassStaplerRelevant(@NonNull Class clazz) { if (clazz.isAnnotationPresent(StaplerAccessibleType.class)) { return true; } @@ -102,7 +102,7 @@ private static boolean isSpecificClassStaplerRelevant(@Nonnull Class clazz) { return false; } - private static boolean isRoutableMethod(@Nonnull Method m) { + private static boolean isRoutableMethod(@NonNull Method m) { for (Annotation a : m.getDeclaredAnnotations()) { if (WebMethodConstants.WEB_METHOD_ANNOTATION_NAMES.contains(a.annotationType().getName())) { return true; @@ -131,7 +131,7 @@ private static boolean isRoutableMethod(@Nonnull Method m) { } @Override - public boolean keep(@Nonnull FieldRef fieldRef) { + public boolean keep(@NonNull FieldRef fieldRef) { if (fieldRef.getAnnotation(StaplerNotDispatchable.class) != null) { // explicitly marked as an invalid field @@ -188,7 +188,7 @@ public boolean keep(@Nonnull FieldRef fieldRef) { } @Override - public boolean keep(@Nonnull Function function) { + public boolean keep(@NonNull Function function) { if (function.getAnnotation(StaplerNotDispatchable.class) != null) { // explicitly marked as an invalid getter diff --git a/core/src/main/java/jenkins/slaves/DefaultJnlpSlaveReceiver.java b/core/src/main/java/jenkins/slaves/DefaultJnlpSlaveReceiver.java index 1d052cff3de7..5d871bd208e0 100644 --- a/core/src/main/java/jenkins/slaves/DefaultJnlpSlaveReceiver.java +++ b/core/src/main/java/jenkins/slaves/DefaultJnlpSlaveReceiver.java @@ -15,8 +15,8 @@ import java.io.PrintWriter; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import jenkins.security.ChannelConfigurator; import jenkins.util.SystemProperties; @@ -83,7 +83,7 @@ private static ComputerLauncher getDelegate(ComputerLauncher launcher) { } @Override - public void afterProperties(@Nonnull JnlpConnectionState event) { + public void afterProperties(@NonNull JnlpConnectionState event) { String clientName = event.getProperty(JnlpConnectionState.CLIENT_NAME_KEY); SlaveComputer computer = (SlaveComputer) Jenkins.get().getComputer(clientName); if (computer == null) { @@ -145,7 +145,7 @@ public void afterProperties(@Nonnull JnlpConnectionState event) { } @Override - public void beforeChannel(@Nonnull JnlpConnectionState event) { + public void beforeChannel(@NonNull JnlpConnectionState event) { DefaultJnlpSlaveReceiver.State state = event.getStash(DefaultJnlpSlaveReceiver.State.class); final SlaveComputer computer = state.getNode(); final OutputStream log = computer.openLogFile(); @@ -163,7 +163,7 @@ public void beforeChannel(@Nonnull JnlpConnectionState event) { } @Override - public void afterChannel(@Nonnull JnlpConnectionState event) { + public void afterChannel(@NonNull JnlpConnectionState event) { DefaultJnlpSlaveReceiver.State state = event.getStash(DefaultJnlpSlaveReceiver.State.class); final SlaveComputer computer = state.getNode(); try { @@ -180,7 +180,7 @@ public void afterChannel(@Nonnull JnlpConnectionState event) { } @Override - public void channelClosed(@Nonnull JnlpConnectionState event) { + public void channelClosed(@NonNull JnlpConnectionState event) { final String nodeName = event.getProperty(JnlpConnectionState.CLIENT_NAME_KEY); IOException cause = event.getCloseCause(); if (cause instanceof ClosedChannelException) { @@ -192,16 +192,16 @@ public void channelClosed(@Nonnull JnlpConnectionState event) { } private static class State implements JnlpConnectionState.ListenerState { - @Nonnull + @NonNull private final SlaveComputer node; @CheckForNull private OutputStream log; - public State(@Nonnull SlaveComputer node) { + public State(@NonNull SlaveComputer node) { this.node = node; } - @Nonnull + @NonNull public SlaveComputer getNode() { return node; } @@ -211,7 +211,7 @@ public OutputStream getLog() { return log; } - public void setLog(@Nonnull OutputStream log) { + public void setLog(@NonNull OutputStream log) { this.log = log; } } diff --git a/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java b/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java index b738b3316a56..3bc25d152de0 100644 --- a/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java +++ b/core/src/main/java/jenkins/slaves/JnlpAgentReceiver.java @@ -5,7 +5,7 @@ import hudson.Util; import hudson.model.Slave; import java.security.SecureRandom; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.agents.WebSocketAgents; import jenkins.security.HMACConfidentialKey; @@ -70,7 +70,7 @@ public boolean exists(String clientName) { } @Override - public String getSecretOf(@Nonnull String clientName) { + public String getSecretOf(@NonNull String clientName) { return SLAVE_SECRET.mac(clientName); } } diff --git a/core/src/main/java/jenkins/slaves/RemotingVersionInfo.java b/core/src/main/java/jenkins/slaves/RemotingVersionInfo.java index d1e0c06e4b55..081747c6ce6b 100644 --- a/core/src/main/java/jenkins/slaves/RemotingVersionInfo.java +++ b/core/src/main/java/jenkins/slaves/RemotingVersionInfo.java @@ -25,7 +25,7 @@ import hudson.util.VersionNumber; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.io.InputStream; import java.util.Properties; @@ -42,10 +42,10 @@ public class RemotingVersionInfo { private static final Logger LOGGER = Logger.getLogger(RemotingVersionInfo.class.getName()); private static final String RESOURCE_NAME="remoting-info.properties"; - @Nonnull + @NonNull private static VersionNumber EMBEDDED_VERSION; - @Nonnull + @NonNull private static VersionNumber MINIMUM_SUPPORTED_VERSION; private RemotingVersionInfo() {} @@ -64,8 +64,8 @@ private RemotingVersionInfo() {} MINIMUM_SUPPORTED_VERSION = extractVersion(props, "remoting.minimum.supported.version"); } - @Nonnull - private static VersionNumber extractVersion(@Nonnull Properties props, @Nonnull String propertyName) + @NonNull + private static VersionNumber extractVersion(@NonNull Properties props, @NonNull String propertyName) throws ExceptionInInitializerError { String prop = props.getProperty(propertyName); if (prop == null) { @@ -93,7 +93,7 @@ private static VersionNumber extractVersion(@Nonnull Properties props, @Nonnull * Note that this version may differ from one which is being really used in Jenkins. * @return Remoting version */ - @Nonnull + @NonNull public static VersionNumber getEmbeddedVersion() { return EMBEDDED_VERSION; } @@ -106,7 +106,7 @@ public static VersionNumber getEmbeddedVersion() { * This method defines a minimum expected version, so that all calls should use a compatible API. * @return Minimal Remoting version for API calls. */ - @Nonnull + @NonNull public static VersionNumber getMinimumSupportedVersion() { return MINIMUM_SUPPORTED_VERSION; } diff --git a/core/src/main/java/jenkins/slaves/RemotingWorkDirSettings.java b/core/src/main/java/jenkins/slaves/RemotingWorkDirSettings.java index f49a34564a6c..b5bb967146ef 100644 --- a/core/src/main/java/jenkins/slaves/RemotingWorkDirSettings.java +++ b/core/src/main/java/jenkins/slaves/RemotingWorkDirSettings.java @@ -32,8 +32,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -58,7 +58,7 @@ public class RemotingWorkDirSettings implements Describable getDescriptor() { * @param computer Computer, for which the arguments are being created * @return Non-modifiable list of command-line arguments */ - public List toCommandLineArgs(@Nonnull SlaveComputer computer) { + public List toCommandLineArgs(@NonNull SlaveComputer computer) { if(disabled) { return Collections.emptyList(); } @@ -170,9 +170,9 @@ public List toCommandLineArgs(@Nonnull SlaveComputer computer) { * It may be empty if the working directory is disabled or * if the Computer type is not {@link SlaveComputer}. */ - @Nonnull + @NonNull @Restricted(NoExternalUse.class) - public String toCommandLineString(@Nonnull SlaveComputer computer) { + public String toCommandLineString(@NonNull SlaveComputer computer) { if(disabled) { return ""; } @@ -214,7 +214,7 @@ public static class DescriptorImpl extends Descriptor { * * @return Legacy value: disabled work directory. */ - @Nonnull + @NonNull public static RemotingWorkDirSettings getDisabledDefaults() { return LEGACY_DEFAULT; } @@ -222,7 +222,7 @@ public static RemotingWorkDirSettings getDisabledDefaults() { /** * Gets default settings of the enabled work directory. */ - @Nonnull + @NonNull public static RemotingWorkDirSettings getEnabledDefaults() { return ENABLED_DEFAULT; } diff --git a/core/src/main/java/jenkins/tasks/SimpleBuildStep.java b/core/src/main/java/jenkins/tasks/SimpleBuildStep.java index 1833343ebc76..8fa6309b1ccc 100644 --- a/core/src/main/java/jenkins/tasks/SimpleBuildStep.java +++ b/core/src/main/java/jenkins/tasks/SimpleBuildStep.java @@ -47,7 +47,7 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.DependencyDeclarer; import jenkins.model.RunAction2; import jenkins.model.TransientActionFactory; @@ -81,8 +81,8 @@ public interface SimpleBuildStep extends BuildStep { * @throws InterruptedException if the step is interrupted * @throws IOException if something goes wrong; use {@link AbortException} for a polite error */ - void perform(@Nonnull Run run, @Nonnull FilePath workspace, @Nonnull Launcher launcher, - @Nonnull TaskListener listener) throws InterruptedException, IOException; + void perform(@NonNull Run run, @NonNull FilePath workspace, @NonNull Launcher launcher, + @NonNull TaskListener listener) throws InterruptedException, IOException; /** * Marker for explicitly added build actions (as {@link Run#addAction}) which should imply a transient project @@ -112,9 +112,9 @@ public Class type() { return Job.class; } - @Nonnull + @NonNull @Override - public Collection createFor(@Nonnull Job j) { + public Collection createFor(@NonNull Job j) { List actions = new LinkedList<>(); Run r = j.getLastSuccessfulBuild(); if (r != null) { diff --git a/core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java b/core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java index 8fcbd3aaff48..ceab8e29969b 100644 --- a/core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java +++ b/core/src/main/java/jenkins/tasks/SimpleBuildWrapper.java @@ -45,8 +45,8 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * A generalization of {@link BuildWrapper} that, like {@link SimpleBuildStep}, may be called at various points within a build. @@ -83,7 +83,7 @@ public abstract class SimpleBuildWrapper extends BuildWrapper { public static final class Context { private Disposer disposer; private final Map env = new HashMap<>(); - public @Nonnull Map getEnv() { + public @NonNull Map getEnv() { return env; } /** @@ -104,7 +104,7 @@ public void env(String key, String value) { * Specify an action to take when the block ends. * If not specified, nothing special happens. */ - public void setDisposer(@Nonnull Disposer disposer) { + public void setDisposer(@NonNull Disposer disposer) { if (this.disposer != null) { throw new IllegalStateException("just one disposer"); } @@ -184,7 +184,7 @@ private class EnvironmentWrapper extends Environment { * @return a filter which ignores its {@code build} parameter and is {@link Serializable}; or null (the default) * @since 1.608 */ - public @CheckForNull ConsoleLogFilter createLoggerDecorator(@Nonnull Run build) { + public @CheckForNull ConsoleLogFilter createLoggerDecorator(@NonNull Run build) { return null; } diff --git a/core/src/main/java/jenkins/telemetry/Telemetry.java b/core/src/main/java/jenkins/telemetry/Telemetry.java index 3de00bc4b82c..6525e0c89a2e 100644 --- a/core/src/main/java/jenkins/telemetry/Telemetry.java +++ b/core/src/main/java/jenkins/telemetry/Telemetry.java @@ -38,8 +38,8 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; @@ -81,7 +81,7 @@ public abstract class Telemetry implements ExtensionPoint { * * @return ID of the collector, never null or empty */ - @Nonnull + @NonNull public String getId() { return getClass().getName(); } @@ -91,7 +91,7 @@ public String getId() { * * @return display name, never null or empty */ - @Nonnull + @NonNull public abstract String getDisplayName(); /** @@ -101,7 +101,7 @@ public String getId() { * * @return collection start date */ - @Nonnull + @NonNull public abstract LocalDate getStart(); /** @@ -111,7 +111,7 @@ public String getId() { * * @return collection end date */ - @Nonnull + @NonNull public abstract LocalDate getEnd(); /** diff --git a/core/src/main/java/jenkins/telemetry/impl/SecuritySystemProperties.java b/core/src/main/java/jenkins/telemetry/impl/SecuritySystemProperties.java index 94fd06cde409..1d63edb5db20 100644 --- a/core/src/main/java/jenkins/telemetry/impl/SecuritySystemProperties.java +++ b/core/src/main/java/jenkins/telemetry/impl/SecuritySystemProperties.java @@ -32,7 +32,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -47,31 +47,31 @@ @Extension @Restricted(NoExternalUse.class) public class SecuritySystemProperties extends Telemetry { - @Nonnull + @NonNull @Override public String getId() { return "security-system-properties"; } - @Nonnull + @NonNull @Override public LocalDate getStart() { return LocalDate.of(2018, 9, 1); } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return LocalDate.of(2018, 12, 1); } - @Nonnull + @NonNull @Override public String getDisplayName() { return "Use of Security-related Java system properties"; } - @Nonnull + @NonNull @Override public JSONObject createContent() { Map security = new TreeMap<>(); diff --git a/core/src/main/java/jenkins/telemetry/impl/StaplerDispatches.java b/core/src/main/java/jenkins/telemetry/impl/StaplerDispatches.java index dd03ce2d4b5e..13115d5c3f4a 100644 --- a/core/src/main/java/jenkins/telemetry/impl/StaplerDispatches.java +++ b/core/src/main/java/jenkins/telemetry/impl/StaplerDispatches.java @@ -35,7 +35,7 @@ import org.kohsuke.stapler.EvaluationTrace; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.time.LocalDate; import java.util.Map; import java.util.Set; @@ -49,19 +49,19 @@ @Extension @Restricted(NoExternalUse.class) public class StaplerDispatches extends Telemetry { - @Nonnull + @NonNull @Override public LocalDate getStart() { return LocalDate.of(2018, 10, 10); } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return LocalDate.of(2019, 8, 1); } - @Nonnull + @NonNull @Override public String getDisplayName() { return "Stapler request handling"; diff --git a/core/src/main/java/jenkins/telemetry/impl/UserLanguages.java b/core/src/main/java/jenkins/telemetry/impl/UserLanguages.java index 3856cea6344b..3d64e32cb7a3 100644 --- a/core/src/main/java/jenkins/telemetry/impl/UserLanguages.java +++ b/core/src/main/java/jenkins/telemetry/impl/UserLanguages.java @@ -31,7 +31,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -55,25 +55,25 @@ public class UserLanguages extends Telemetry { private static final Map requestsByLanguage = new ConcurrentSkipListMap<>(); private static Logger LOGGER = Logger.getLogger(UserLanguages.class.getName()); - @Nonnull + @NonNull @Override public String getId() { return UserLanguages.class.getName(); } - @Nonnull + @NonNull @Override public String getDisplayName() { return "Browser languages"; } - @Nonnull + @NonNull @Override public LocalDate getStart() { return LocalDate.of(2018, 10, 1); } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return LocalDate.of(2019, 1, 1); diff --git a/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvent.java b/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvent.java index a8c1484fa2c6..ab13224f97ca 100644 --- a/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvent.java +++ b/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvent.java @@ -24,7 +24,7 @@ package jenkins.telemetry.impl.java11; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.PrintWriter; import java.io.StringWriter; @@ -53,7 +53,7 @@ void setClassName(String className) { this.className = className; } - MissingClassEvent(@Nonnull String name, @Nonnull Throwable t) { + MissingClassEvent(@NonNull String name, @NonNull Throwable t) { this.className = name; StringWriter stackTrace = new StringWriter(); diff --git a/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvents.java b/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvents.java index 563f655c72fe..2b7b2737e1d7 100644 --- a/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvents.java +++ b/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassEvents.java @@ -26,7 +26,7 @@ import com.google.common.annotations.VisibleForTesting; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -54,7 +54,7 @@ public class MissingClassEvents { * @return the occurrences stored for this throwable. 1 the fist time it's stored. > 1 for successive stores of the * same stack trace. 0 if we already stored MAX_EVENTS_PER_SEND (100) events for a single send. */ - public long put(String name, @Nonnull Throwable t) { + public long put(String name, @NonNull Throwable t) { // A final object to pass it to the function final AtomicLong occurrences = new AtomicLong(); @@ -92,7 +92,7 @@ public long put(String name, @Nonnull Throwable t) { */ @VisibleForTesting - /* package */ synchronized @Nonnull ConcurrentHashMap, MissingClassEvent> getEventsAndClean() { + /* package */ synchronized @NonNull ConcurrentHashMap, MissingClassEvent> getEventsAndClean() { ConcurrentHashMap, MissingClassEvent> currentEvents = events; events = new ConcurrentHashMap<>(MAX_EVENTS_PER_SEND); return currentEvents; diff --git a/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassTelemetry.java b/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassTelemetry.java index 65260a9cb08f..c962ca2b9893 100644 --- a/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassTelemetry.java +++ b/core/src/main/java/jenkins/telemetry/impl/java11/MissingClassTelemetry.java @@ -36,8 +36,8 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.time.LocalDate; @@ -111,19 +111,19 @@ public class MissingClassTelemetry extends Telemetry { }; - @Nonnull + @NonNull @Override public String getDisplayName() { return "Missing classes related with Java updates"; } - @Nonnull + @NonNull @Override public LocalDate getStart() { return START; } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return END; @@ -175,7 +175,7 @@ public JSONObject createContent() { * gather another window of events. * @return the map of missed classes events gathered along this window of telemetry */ - @Nonnull + @NonNull private JSONArray formatEventsAndInitialize() { // Save the current events and clean for next (not this one) telemetry send ConcurrentHashMap, MissingClassEvent> toReport = MissingClassTelemetry.events.getEventsAndClean(); @@ -194,8 +194,8 @@ private JSONArray formatEventsAndInitialize() { * @param events events collected in this telemetry window. * @return the events formatted in a map. */ - @Nonnull - private JSONArray formatEvents(@Nonnull ConcurrentHashMap, MissingClassEvent> events) { + @NonNull + private JSONArray formatEvents(@NonNull ConcurrentHashMap, MissingClassEvent> events) { JSONArray jsonEvents = new JSONArray(); events.forEach((stackTrace, event) -> { @@ -216,7 +216,7 @@ private JSONArray formatEvents(@Nonnull ConcurrentHashMap exceptionsReviewed = Collections.newSetFromMap(new IdentityHashMap<>()); @@ -326,7 +326,7 @@ public static void reportExceptionInside(@Nonnull Throwable e) { * @param exceptionsReviewed the set of already reviewed exceptions * @return true if a exception was reported */ - private static boolean reportExceptionInside(@Nonnull Throwable e, @Nonnull Set exceptionsReviewed) { + private static boolean reportExceptionInside(@NonNull Throwable e, @NonNull Set exceptionsReviewed) { if (exceptionsReviewed.contains(e)) { LOGGER.log(Level.WARNING, CIRCULAR_REFERENCE, e); // Don't go deeper, we already did diff --git a/core/src/main/java/jenkins/tools/GlobalToolConfiguration.java b/core/src/main/java/jenkins/tools/GlobalToolConfiguration.java index aa890ce9ffdf..ef2a0140daed 100644 --- a/core/src/main/java/jenkins/tools/GlobalToolConfiguration.java +++ b/core/src/main/java/jenkins/tools/GlobalToolConfiguration.java @@ -39,7 +39,7 @@ import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.verb.POST; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletException; import java.io.IOException; import java.util.logging.Level; @@ -74,7 +74,7 @@ public Permission getRequiredPermission() { return Jenkins.ADMINISTER; } - @Nonnull + @NonNull @Override public Category getCategory() { return Category.CONFIGURATION; diff --git a/core/src/main/java/jenkins/triggers/ReverseBuildTrigger.java b/core/src/main/java/jenkins/triggers/ReverseBuildTrigger.java index b9161fd7e3b4..c0dbc11ebf91 100644 --- a/core/src/main/java/jenkins/triggers/ReverseBuildTrigger.java +++ b/core/src/main/java/jenkins/triggers/ReverseBuildTrigger.java @@ -74,8 +74,8 @@ import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Like {@link BuildTrigger} but defined on the downstream project. @@ -181,7 +181,7 @@ private boolean shouldTrigger(Run upstreamBuild, TaskListener listener) { } } - @Override public void start(@Nonnull Job project, boolean newInstance) { + @Override public void start(@NonNull Job project, boolean newInstance) { super.start(project, newInstance); RunListenerImpl.get().invalidateCache(); } @@ -270,7 +270,7 @@ private Map> calculateCache() { } } - @Override public void onCompleted(@Nonnull Run r, @Nonnull TaskListener listener) { + @Override public void onCompleted(@NonNull Run r, @NonNull TaskListener listener) { Collection triggers; synchronized (this) { if (upstream2Trigger == null) { diff --git a/core/src/main/java/jenkins/triggers/SCMTriggerItem.java b/core/src/main/java/jenkins/triggers/SCMTriggerItem.java index d9b04d38cc6c..bfa8544ffb69 100644 --- a/core/src/main/java/jenkins/triggers/SCMTriggerItem.java +++ b/core/src/main/java/jenkins/triggers/SCMTriggerItem.java @@ -37,8 +37,8 @@ import java.util.Collections; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.ParameterizedJobMixIn; import jenkins.scm.SCMDecisionHandler; @@ -70,7 +70,7 @@ public interface SCMTriggerItem { * The implementation is responsible for checking the {@link SCMDecisionHandler} before proceeding * with the actual polling. */ - @Nonnull PollingResult poll(@Nonnull TaskListener listener); + @NonNull PollingResult poll(@NonNull TaskListener listener); @CheckForNull SCMTrigger getSCMTrigger(); @@ -79,7 +79,7 @@ public interface SCMTriggerItem { * May be used for informational purposes, or to determine whether to initiate polling. * @return a possibly empty collection */ - @Nonnull Collection getSCMs(); + @NonNull Collection getSCMs(); /** * Schedules a polling of this project. @@ -150,7 +150,7 @@ private static final class Bridge implements SCMTriggerItem { } } - public static @Nonnull Collection resolveMultiScmIfConfigured(@CheckForNull SCM scm) { + public static @NonNull Collection resolveMultiScmIfConfigured(@CheckForNull SCM scm) { if (scm == null || scm instanceof NullSCM) { return Collections.emptySet(); } else if (scm.getClass().getName().equals("org.jenkinsci.plugins.multiplescms.MultiSCM")) { diff --git a/core/src/main/java/jenkins/util/AntClassLoader.java b/core/src/main/java/jenkins/util/AntClassLoader.java index 44bcc75ef1af..7843abb69ae9 100644 --- a/core/src/main/java/jenkins/util/AntClassLoader.java +++ b/core/src/main/java/jenkins/util/AntClassLoader.java @@ -32,8 +32,8 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.Nonnull; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -769,7 +769,7 @@ private InputStream loadBaseResource(String name) { @FunctionalInterface private interface Converter { - T convert(@Nonnull JarFile jarFile, @Nonnull JarEntry entry) throws IOException; + T convert(@NonNull JarFile jarFile, @NonNull JarEntry entry) throws IOException; } @CheckForNull diff --git a/core/src/main/java/jenkins/util/ProgressiveRendering.java b/core/src/main/java/jenkins/util/ProgressiveRendering.java index cdf2055e760e..137ca68b63b2 100644 --- a/core/src/main/java/jenkins/util/ProgressiveRendering.java +++ b/core/src/main/java/jenkins/util/ProgressiveRendering.java @@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.http.HttpServletRequest; import net.sf.json.JSON; import net.sf.json.JSONObject; @@ -224,7 +224,7 @@ private static void setCurrentRequest(RequestImpl request) { * on the same monitor such as {@code this}. * @return any JSON data you like */ - protected abstract @Nonnull JSON data(); + protected abstract @NonNull JSON data(); /** * Indicate what portion of the work has been done. diff --git a/core/src/main/java/jenkins/util/ResourceBundleUtil.java b/core/src/main/java/jenkins/util/ResourceBundleUtil.java index b2eee336abc1..64a650c0cf10 100644 --- a/core/src/main/java/jenkins/util/ResourceBundleUtil.java +++ b/core/src/main/java/jenkins/util/ResourceBundleUtil.java @@ -27,8 +27,8 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.PluginWrapper; import java.util.logging.Logger; import java.util.Locale; @@ -58,7 +58,7 @@ private ResourceBundleUtil() { * @return The bundle JSON. * @throws MissingResourceException Missing resource bundle. */ - public static @Nonnull JSONObject getBundle(@Nonnull String baseName) throws MissingResourceException { + public static @NonNull JSONObject getBundle(@NonNull String baseName) throws MissingResourceException { return getBundle(baseName, Locale.getDefault()); } @@ -69,7 +69,7 @@ private ResourceBundleUtil() { * @return The bundle JSON. * @throws MissingResourceException Missing resource bundle. */ - public static @Nonnull JSONObject getBundle(@Nonnull String baseName, @Nonnull Locale locale) throws MissingResourceException { + public static @NonNull JSONObject getBundle(@NonNull String baseName, @NonNull Locale locale) throws MissingResourceException { String bundleKey = baseName + ":" + locale.toString(); JSONObject bundleJSON = bundles.get(bundleKey); @@ -109,7 +109,7 @@ private ResourceBundleUtil() { * @param classLoader The classLoader * @return The bundle JSON. */ - private static @CheckForNull ResourceBundle getBundle(@Nonnull String baseName, @Nonnull Locale locale, @Nonnull ClassLoader classLoader) { + private static @CheckForNull ResourceBundle getBundle(@NonNull String baseName, @NonNull Locale locale, @NonNull ClassLoader classLoader) { try { return ResourceBundle.getBundle(baseName, locale, classLoader); } catch (MissingResourceException e) { @@ -125,7 +125,7 @@ private ResourceBundleUtil() { * @param bundle The resource bundle. * @return The bundle JSON. */ - private static JSONObject toJSONObject(@Nonnull ResourceBundle bundle) { + private static JSONObject toJSONObject(@NonNull ResourceBundle bundle) { JSONObject json = new JSONObject(); for (String key : bundle.keySet()) { json.put(key, bundle.getString(key)); diff --git a/core/src/main/java/jenkins/util/SystemProperties.java b/core/src/main/java/jenkins/util/SystemProperties.java index ef79a782ebd5..c34aae85af24 100644 --- a/core/src/main/java/jenkins/util/SystemProperties.java +++ b/core/src/main/java/jenkins/util/SystemProperties.java @@ -39,8 +39,8 @@ import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; @@ -87,7 +87,7 @@ private interface Handler { private static final Handler NULL_HANDLER = key -> null; - private static @Nonnull Handler handler = NULL_HANDLER; + private static @NonNull Handler handler = NULL_HANDLER; // declared in WEB-INF/web.xml public static final class Listener implements ServletContextListener, OnMaster { diff --git a/core/src/main/java/jenkins/util/TimeDuration.java b/core/src/main/java/jenkins/util/TimeDuration.java index 8b0fff3f5eda..1422ffafe499 100644 --- a/core/src/main/java/jenkins/util/TimeDuration.java +++ b/core/src/main/java/jenkins/util/TimeDuration.java @@ -4,7 +4,7 @@ import org.kohsuke.stapler.QueryParameter; import java.util.concurrent.TimeUnit; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Represents a length of something, like {@code 3sec}. diff --git a/core/src/main/java/jenkins/util/Timer.java b/core/src/main/java/jenkins/util/Timer.java index 7451bf689217..3dd80b216643 100644 --- a/core/src/main/java/jenkins/util/Timer.java +++ b/core/src/main/java/jenkins/util/Timer.java @@ -4,7 +4,7 @@ import hudson.util.ClassLoaderSanityThreadFactory; import hudson.util.DaemonThreadFactory; import hudson.util.NamingThreadFactory; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.concurrent.ScheduledExecutorService; import jenkins.security.ImpersonatingScheduledExecutorService; @@ -38,7 +38,7 @@ public class Timer { * * @return the single {@link ScheduledExecutorService}. */ - @Nonnull + @NonNull public static synchronized ScheduledExecutorService get() { if (executorService == null) { // corePoolSize is set to 10, but will only be created if needed. diff --git a/core/src/main/java/jenkins/util/VirtualFile.java b/core/src/main/java/jenkins/util/VirtualFile.java index 80a747143bb3..8cec34a569ad 100644 --- a/core/src/main/java/jenkins/util/VirtualFile.java +++ b/core/src/main/java/jenkins/util/VirtualFile.java @@ -54,8 +54,8 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.MasterToSlaveFileCallable; import jenkins.model.ArtifactManager; @@ -114,7 +114,7 @@ public abstract class VirtualFile implements Comparable, Serializab * For a “root directory” this may be the empty string. * @return a simple name (no slashes) */ - public abstract @Nonnull String getName(); + public abstract @NonNull String getName(); /** * Gets a URI. @@ -123,7 +123,7 @@ public abstract class VirtualFile implements Comparable, Serializab * unless some sort of authentication is also embedded. * @return a URI (need not be absolute) */ - public abstract @Nonnull URI toURI(); + public abstract @NonNull URI toURI(); /** * Gets the parent file. @@ -173,7 +173,7 @@ public abstract class VirtualFile implements Comparable, Serializab * @return a list of children (files and subdirectories); empty for a file or nonexistent directory * @throws IOException if this directory exists but listing was not possible for some other reason */ - public abstract @Nonnull VirtualFile[] list() throws IOException; + public abstract @NonNull VirtualFile[] list() throws IOException; @Restricted(NoExternalUse.class) public boolean supportsQuickRecursiveListing() { @@ -188,7 +188,7 @@ public boolean supportsQuickRecursiveListing() { * @throws IOException if this directory exists but listing was not possible for some other reason */ @Restricted(NoExternalUse.class) - public @Nonnull List listOnlyDescendants() throws IOException { + public @NonNull List listOnlyDescendants() throws IOException { VirtualFile[] children = list(); List result = new ArrayList<>(); for (VirtualFile child : children) { @@ -203,7 +203,7 @@ public boolean supportsQuickRecursiveListing() { * @deprecated use {@link #list(String, String, boolean)} instead */ @Deprecated - public @Nonnull String[] list(String glob) throws IOException { + public @NonNull String[] list(String glob) throws IOException { return list(glob.replace('\\', '/'), null, true).toArray(MemoryReductionUtil.EMPTY_STRING_ARRAY); } @@ -220,7 +220,7 @@ public boolean supportsQuickRecursiveListing() { * @since 2.118 */ @Restricted(Beta.class) - public @Nonnull Collection list(@Nonnull String includes, @CheckForNull String excludes, boolean useDefaultExcludes) throws IOException { + public @NonNull Collection list(@NonNull String includes, @CheckForNull String excludes, boolean useDefaultExcludes) throws IOException { Collection r = run(new CollectFiles(this)); List includePatterns = patterns(includes); List excludePatterns = patterns(excludes); @@ -274,7 +274,7 @@ private List patterns(String patts) { * @param name a relative path, possibly including {@code /} (but not {@code ..}) * @return a representation of that child, whether it actually exists or not */ - public abstract @Nonnull VirtualFile child(@Nonnull String name); + public abstract @NonNull VirtualFile child(@NonNull String name); /** * Gets the file length. @@ -479,7 +479,7 @@ private static final class FileVF extends VirtualFile { return true; } - @Override public @Nonnull List listOnlyDescendants() throws IOException { + @Override public @NonNull List listOnlyDescendants() throws IOException { if (isIllegalSymlink()) { return Collections.emptyList(); } @@ -699,7 +699,7 @@ private static final class FilePathVF extends VirtualFile { return this.f.getChannel() == FilePath.localChannel; } - @Override public @Nonnull List listOnlyDescendants() throws IOException { + @Override public @NonNull List listOnlyDescendants() throws IOException { try { if (!isDescendant("")) { return Collections.emptyList(); diff --git a/core/src/main/java/jenkins/util/groovy/GroovyHookScript.java b/core/src/main/java/jenkins/util/groovy/GroovyHookScript.java index 638992fc2098..51b2ed96475e 100644 --- a/core/src/main/java/jenkins/util/groovy/GroovyHookScript.java +++ b/core/src/main/java/jenkins/util/groovy/GroovyHookScript.java @@ -12,7 +12,7 @@ import java.util.TreeSet; import static java.util.logging.Level.WARNING; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.ServletContext; import jenkins.model.Jenkins; @@ -53,7 +53,7 @@ private GroovyHookScript(String hook, Jenkins j) { this(hook, j.servletContext, j.getRootDir(), j.getPluginManager().uberClassLoader); } - public GroovyHookScript(String hook, @Nonnull ServletContext servletContext, @Nonnull File home, @Nonnull ClassLoader loader) { + public GroovyHookScript(String hook, @NonNull ServletContext servletContext, @NonNull File home, @NonNull ClassLoader loader) { this.hook = hook; this.servletContext = servletContext; this.home = home; diff --git a/core/src/main/java/jenkins/util/io/CompositeIOException.java b/core/src/main/java/jenkins/util/io/CompositeIOException.java index 04090859f47a..f6ddfa246c08 100644 --- a/core/src/main/java/jenkins/util/io/CompositeIOException.java +++ b/core/src/main/java/jenkins/util/io/CompositeIOException.java @@ -27,7 +27,7 @@ import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.io.UncheckedIOException; import java.util.Arrays; @@ -37,7 +37,7 @@ public class CompositeIOException extends IOException { private final List exceptions; - public CompositeIOException(String message, @Nonnull List exceptions) { + public CompositeIOException(String message, @NonNull List exceptions) { super(message); this.exceptions = exceptions; exceptions.forEach(this::addSuppressed); diff --git a/core/src/main/java/jenkins/util/io/LinesStream.java b/core/src/main/java/jenkins/util/io/LinesStream.java index 0925b3492956..92ff49cb0196 100644 --- a/core/src/main/java/jenkins/util/io/LinesStream.java +++ b/core/src/main/java/jenkins/util/io/LinesStream.java @@ -35,8 +35,8 @@ import java.nio.file.Path; import java.util.Iterator; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; /** * Represents a stream over the lines of a text file. @@ -63,7 +63,7 @@ @CleanupObligation public class LinesStream implements Closeable, Iterable { - private final @Nonnull BufferedReader in; + private final @NonNull BufferedReader in; private transient @Nullable Iterator iterator; /** @@ -73,7 +73,7 @@ public class LinesStream implements Closeable, Iterable { * @throws IOException if the file at {@code path} cannot be opened for * reading. */ - public LinesStream(@Nonnull Path path) throws IOException { + public LinesStream(@NonNull Path path) throws IOException { in = Files.newBufferedReader(path); // uses UTF-8 by default } diff --git a/core/src/main/java/jenkins/util/io/PathRemover.java b/core/src/main/java/jenkins/util/io/PathRemover.java index 570a8e1877e8..045592d9221e 100644 --- a/core/src/main/java/jenkins/util/io/PathRemover.java +++ b/core/src/main/java/jenkins/util/io/PathRemover.java @@ -40,7 +40,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -56,23 +56,23 @@ public static PathRemover newSimpleRemover() { return new PathRemover(ignored -> false, PathChecker.ALLOW_ALL); } - public static PathRemover newRemoverWithStrategy(@Nonnull RetryStrategy retryStrategy) { + public static PathRemover newRemoverWithStrategy(@NonNull RetryStrategy retryStrategy) { return new PathRemover(retryStrategy, PathChecker.ALLOW_ALL); } - public static PathRemover newFilteredRobustRemover(@Nonnull PathChecker pathChecker, int maxRetries, boolean gcAfterFailedRemove, long waitBetweenRetries) { + public static PathRemover newFilteredRobustRemover(@NonNull PathChecker pathChecker, int maxRetries, boolean gcAfterFailedRemove, long waitBetweenRetries) { return new PathRemover(new PausingGCRetryStrategy(Math.max(maxRetries, 0), gcAfterFailedRemove, waitBetweenRetries), pathChecker); } private final RetryStrategy retryStrategy; private final PathChecker pathChecker; - private PathRemover(@Nonnull RetryStrategy retryStrategy, @Nonnull PathChecker pathChecker) { + private PathRemover(@NonNull RetryStrategy retryStrategy, @NonNull PathChecker pathChecker) { this.retryStrategy = retryStrategy; this.pathChecker = pathChecker; } - public void forceRemoveFile(@Nonnull Path path) throws IOException { + public void forceRemoveFile(@NonNull Path path) throws IOException { for (int retryAttempts = 0; ; retryAttempts++) { Optional maybeError = tryRemoveFile(path); if (!maybeError.isPresent()) return; @@ -82,7 +82,7 @@ public void forceRemoveFile(@Nonnull Path path) throws IOException { } } - public void forceRemoveDirectoryContents(@Nonnull Path path) throws IOException { + public void forceRemoveDirectoryContents(@NonNull Path path) throws IOException { for (int retryAttempt = 0; ; retryAttempt++) { List errors = tryRemoveDirectoryContents(path); if (errors.isEmpty()) return; @@ -91,7 +91,7 @@ public void forceRemoveDirectoryContents(@Nonnull Path path) throws IOException } } - public void forceRemoveRecursive(@Nonnull Path path) throws IOException { + public void forceRemoveRecursive(@NonNull Path path) throws IOException { for (int retryAttempt = 0; ; retryAttempt++) { List errors = tryRemoveRecursive(path); if (errors.isEmpty()) return; @@ -103,7 +103,7 @@ public void forceRemoveRecursive(@Nonnull Path path) throws IOException { @Restricted(NoExternalUse.class) @FunctionalInterface public interface PathChecker { - void check(@Nonnull Path path) throws SecurityException; + void check(@NonNull Path path) throws SecurityException; PathChecker ALLOW_ALL = path -> {}; } @@ -113,7 +113,7 @@ public interface PathChecker { public interface RetryStrategy { boolean shouldRetry(int retriesAttempted); - default String failureMessage(@Nonnull Path fileToRemove, int retryCount) { + default String failureMessage(@NonNull Path fileToRemove, int retryCount) { StringBuilder sb = new StringBuilder() .append("Unable to delete '") .append(fileToRemove) @@ -165,7 +165,7 @@ public boolean shouldRetry(int retriesAttempted) { } @Override - public String failureMessage(@Nonnull Path fileToRemove, int retryCount) { + public String failureMessage(@NonNull Path fileToRemove, int retryCount) { StringBuilder sb = new StringBuilder(); sb.append("Unable to delete '"); sb.append(fileToRemove); @@ -200,7 +200,7 @@ public String failureMessage(@Nonnull Path fileToRemove, int retryCount) { } } - private Optional tryRemoveFile(@Nonnull Path path) { + private Optional tryRemoveFile(@NonNull Path path) { try { removeOrMakeRemovableThenRemove(path.normalize()); return Optional.empty(); @@ -209,7 +209,7 @@ private Optional tryRemoveFile(@Nonnull Path path) { } } - private List tryRemoveRecursive(@Nonnull Path path) { + private List tryRemoveRecursive(@NonNull Path path) { Path normalized = path.normalize(); List accumulatedErrors = Util.isSymlink(normalized) ? new ArrayList<>() : tryRemoveDirectoryContents(normalized); @@ -217,7 +217,7 @@ private List tryRemoveRecursive(@Nonnull Path path) { return accumulatedErrors; } - private List tryRemoveDirectoryContents(@Nonnull Path path) { + private List tryRemoveDirectoryContents(@NonNull Path path) { Path normalized = path.normalize(); List accumulatedErrors = new ArrayList<>(); if (!Files.isDirectory(normalized)) return accumulatedErrors; @@ -231,7 +231,7 @@ private List tryRemoveDirectoryContents(@Nonnull Path path) { return accumulatedErrors; } - private void removeOrMakeRemovableThenRemove(@Nonnull Path path) throws IOException { + private void removeOrMakeRemovableThenRemove(@NonNull Path path) throws IOException { pathChecker.check(path); try { Files.deleteIfExists(path); @@ -254,7 +254,7 @@ private void removeOrMakeRemovableThenRemove(@Nonnull Path path) throws IOExcept } } - private static void makeRemovable(@Nonnull Path path) throws IOException { + private static void makeRemovable(@NonNull Path path) throws IOException { if (!Files.isWritable(path)) { makeWritable(path); } @@ -277,7 +277,7 @@ private static void makeRemovable(@Nonnull Path path) throws IOException { } } - private static void makeWritable(@Nonnull Path path) throws IOException { + private static void makeWritable(@NonNull Path path) throws IOException { if (!Functions.isWindows()) { try { PosixFileAttributes attrs = Files.readAttributes(path, PosixFileAttributes.class); diff --git a/core/src/main/java/jenkins/util/xml/XMLUtils.java b/core/src/main/java/jenkins/util/xml/XMLUtils.java index a47abf19f224..cc672bb8eedc 100644 --- a/core/src/main/java/jenkins/util/xml/XMLUtils.java +++ b/core/src/main/java/jenkins/util/xml/XMLUtils.java @@ -18,7 +18,7 @@ import java.util.logging.Level; import java.util.logging.LogManager; import java.util.logging.Logger; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -55,7 +55,7 @@ public final class XMLUtils { * {@link SAXSource} in order to be able to prevent XXE attacks. * @param out The Result of transforming the {@code source}. */ - public static void safeTransform(@Nonnull Source source, @Nonnull Result out) throws TransformerException, + public static void safeTransform(@NonNull Source source, @NonNull Result out) throws TransformerException, SAXException { InputSource src = SAXSource.sourceToInputSource(source); @@ -110,7 +110,7 @@ public static void safeTransform(@Nonnull Source source, @Nonnull Result out) th * @throws IOException Error reading from the steam. * @since 2.0 */ - public static @Nonnull Document parse(@Nonnull Reader stream) throws SAXException, IOException { + public static @NonNull Document parse(@NonNull Reader stream) throws SAXException, IOException { DocumentBuilder docBuilder; try { @@ -132,7 +132,7 @@ public static void safeTransform(@Nonnull Source source, @Nonnull Result out) th * @throws IOException Error reading from the file. * @since 2.0 */ - public static @Nonnull Document parse(@Nonnull File file, @Nonnull String encoding) throws SAXException, IOException { + public static @NonNull Document parse(@NonNull File file, @NonNull String encoding) throws SAXException, IOException { if (!file.exists() || !file.isFile()) { throw new IllegalArgumentException(String.format("File %s does not exist or is not a 'normal' file.", file.getAbsolutePath())); } @@ -159,7 +159,7 @@ public static void safeTransform(@Nonnull Source source, @Nonnull Result out) th * @throws XPathExpressionException Invalid XPath expression. * @since 2.0 */ - public static @Nonnull String getValue(@Nonnull String xpath, @Nonnull File file) throws IOException, SAXException, XPathExpressionException { + public static @NonNull String getValue(@NonNull String xpath, @NonNull File file) throws IOException, SAXException, XPathExpressionException { return getValue(xpath, file, Charset.defaultCharset().toString()); } @@ -175,7 +175,7 @@ public static void safeTransform(@Nonnull Source source, @Nonnull Result out) th * @throws XPathExpressionException Invalid XPath expression. * @since 2.0 */ - public static @Nonnull String getValue(@Nonnull String xpath, @Nonnull File file, @Nonnull String fileDataEncoding) throws IOException, SAXException, XPathExpressionException { + public static @NonNull String getValue(@NonNull String xpath, @NonNull File file, @NonNull String fileDataEncoding) throws IOException, SAXException, XPathExpressionException { Document document = parse(file, fileDataEncoding); return getValue(xpath, document); } diff --git a/core/src/main/java/jenkins/widgets/HistoryPageEntry.java b/core/src/main/java/jenkins/widgets/HistoryPageEntry.java index b3aeaecedb82..9c11dceb7f58 100644 --- a/core/src/main/java/jenkins/widgets/HistoryPageEntry.java +++ b/core/src/main/java/jenkins/widgets/HistoryPageEntry.java @@ -26,7 +26,7 @@ import hudson.model.Queue; import hudson.model.Run; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; /** * Represents an entry used by the {@link HistoryPageFilter}. @@ -54,7 +54,7 @@ public long getEntryId() { return getEntryId(entry); } - protected static long getEntryId(@Nonnull Object entry) { + protected static long getEntryId(@NonNull Object entry) { if (entry instanceof Queue.Item) { return ((Queue.Item) entry).getId(); } else if (entry instanceof Run) { diff --git a/core/src/main/java/jenkins/widgets/HistoryPageFilter.java b/core/src/main/java/jenkins/widgets/HistoryPageFilter.java index 5f01c557c23c..7ff9b94453e3 100644 --- a/core/src/main/java/jenkins/widgets/HistoryPageFilter.java +++ b/core/src/main/java/jenkins/widgets/HistoryPageFilter.java @@ -34,7 +34,7 @@ import hudson.util.Iterators; import hudson.widgets.HistoryWidget; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.ArrayList; import java.util.Comparator; import java.util.Iterator; @@ -102,7 +102,7 @@ public void setOlderThan(Long olderThan) { * Set the search string used to narrow the filtered set of builds. * @param searchString The search string. */ - public void setSearchString(@Nonnull String searchString) { + public void setSearchString(@NonNull String searchString) { this.searchString = searchString; } @@ -113,7 +113,7 @@ public void setSearchString(@Nonnull String searchString) { * @deprecated Replaced by add(Iterable<T>) as of version 2.15 */ @Deprecated - public void add(@Nonnull List runItems) { + public void add(@NonNull List runItems) { addInternal(runItems); } @@ -123,7 +123,7 @@ public void add(@Nonnull List runItems) { * @param runItems The items to be added. Assumes the items are in descending queue ID order i.e. newest first. * @since 2.17 */ - public void add(@Nonnull Iterable runItems) { + public void add(@NonNull Iterable runItems) { addInternal(runItems); } @@ -134,7 +134,7 @@ public void add(@Nonnull Iterable runItems) { * @param queueItems The queue items to be added. Queue items do not need to be sorted. * @since 2.17 */ - public void add(@Nonnull Iterable runItems, @Nonnull List queueItems) { + public void add(@NonNull Iterable runItems, @NonNull List queueItems) { sort(queueItems); addInternal(Iterables.concat(queueItems, runItems)); } @@ -144,7 +144,7 @@ public void add(@Nonnull Iterable runItems, @Nonnull List queueIt * @param items The items to be added. * @param The type of items should either be T or Queue.Item. */ - private void addInternal(@Nonnull Iterable items) { + private void addInternal(@NonNull Iterable items) { // Note that items can be a large lazily evaluated collection, // so this method is optimized to only iterate through it as much as needed. @@ -245,7 +245,7 @@ public int compare(Object o1, Object o2) { }); } - private long getNextBuildNumber(@Nonnull Object entry) { + private long getNextBuildNumber(@NonNull Object entry) { if (entry instanceof Queue.Item) { Queue.Task task = ((Queue.Item) entry).task; if (task instanceof Job) { @@ -316,7 +316,7 @@ private int getFillCount() { return Math.max(0, (maxEntries - size())); } - private boolean fitsSearchParams(@Nonnull Queue.Item item) { + private boolean fitsSearchParams(@NonNull Queue.Item item) { if (fitsSearchString(item.getDisplayName())) { return true; } else if (fitsSearchString(item.getId())) { @@ -326,7 +326,7 @@ private boolean fitsSearchParams(@Nonnull Queue.Item item) { return false; } - private boolean fitsSearchParams(@Nonnull Run run) { + private boolean fitsSearchParams(@NonNull Run run) { if (searchString == null) { return true; } diff --git a/core/src/main/resources/META-INF/upgrade/JSR-305.hint b/core/src/main/resources/META-INF/upgrade/JSR-305.hint new file mode 100644 index 000000000000..cc030286af7f --- /dev/null +++ b/core/src/main/resources/META-INF/upgrade/JSR-305.hint @@ -0,0 +1,3 @@ +javax.annotation.CheckForNull => edu.umd.cs.findbugs.annotations.CheckForNull;; +javax.annotation.Nonnull => edu.umd.cs.findbugs.annotations.NonNull;; +javax.annotation.Nullable => edu.umd.cs.findbugs.annotations.Nullable;; \ No newline at end of file diff --git a/core/src/test/java/hudson/model/FingerprintCleanupThreadTest.java b/core/src/test/java/hudson/model/FingerprintCleanupThreadTest.java index 7cf2d780d484..54c36ec678c3 100644 --- a/core/src/test/java/hudson/model/FingerprintCleanupThreadTest.java +++ b/core/src/test/java/hudson/model/FingerprintCleanupThreadTest.java @@ -25,7 +25,7 @@ import org.junit.Test; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; @@ -147,7 +147,7 @@ private static class TestTaskListener implements TaskListener { private ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); private PrintStream logStream = new PrintStream(outputStream); - @Nonnull + @NonNull @Override public PrintStream getLogger() { return logStream; diff --git a/core/src/test/java/hudson/util/AtomicFileWriterTest.java b/core/src/test/java/hudson/util/AtomicFileWriterTest.java index 2c0308d13ec1..e36a325c5bce 100644 --- a/core/src/test/java/hudson/util/AtomicFileWriterTest.java +++ b/core/src/test/java/hudson/util/AtomicFileWriterTest.java @@ -8,7 +8,7 @@ import org.junit.rules.TemporaryFolder; import org.jvnet.hudson.test.Issue; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.Nullable; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; diff --git a/core/src/test/java/jenkins/util/io/FileLockerRule.java b/core/src/test/java/jenkins/util/io/FileLockerRule.java index df0dab652e7e..2607131392b2 100644 --- a/core/src/test/java/jenkins/util/io/FileLockerRule.java +++ b/core/src/test/java/jenkins/util/io/FileLockerRule.java @@ -27,7 +27,7 @@ import hudson.Functions; import org.junit.rules.ExternalResource; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.Closeable; import java.io.File; import java.io.FileInputStream; @@ -65,14 +65,14 @@ protected void after() { throw new CompositeIOException("Could not unlock all files", exceptions).asUncheckedIOException(); } - public synchronized void acquireLock(@Nonnull File file) throws IOException { + public synchronized void acquireLock(@NonNull File file) throws IOException { assertTrue(Functions.isWindows()); assertThat(file + " is already locked.", locks, not(hasKey(file))); Closeable lock = new FileInputStream(file); locks.put(file, lock); } - public synchronized void releaseLock(@Nonnull File file) throws Exception { + public synchronized void releaseLock(@NonNull File file) throws Exception { assertTrue(Functions.isWindows()); assertThat(file + " is not locked.", locks, hasKey(file)); locks.remove(file).close(); diff --git a/pom.xml b/pom.xml index 7c773160131c..bc8dac441687 100755 --- a/pom.xml +++ b/pom.xml @@ -421,6 +421,35 @@ THE SOFTWARE. 768 + + org.apache.maven.plugins + maven-checkstyle-plugin + 3.1.1 + + true + true + + + + + + + + + + + + + + + validate + validate + + check + + + + @@ -508,7 +537,10 @@ THE SOFTWARE. - + + + org.apache.maven.plugins + maven-checkstyle-plugin diff --git a/test/src/test/java/hudson/AbstractItemSecurity1114Test.java b/test/src/test/java/hudson/AbstractItemSecurity1114Test.java index 7ae50a17f655..e54aab990f9a 100644 --- a/test/src/test/java/hudson/AbstractItemSecurity1114Test.java +++ b/test/src/test/java/hudson/AbstractItemSecurity1114Test.java @@ -16,7 +16,7 @@ import org.jvnet.hudson.test.MockAuthorizationStrategy; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; public class AbstractItemSecurity1114Test { @Rule diff --git a/test/src/test/java/hudson/model/ApiSEC1704Test.java b/test/src/test/java/hudson/model/ApiSEC1704Test.java index 3aca1048b570..69d6323499aa 100644 --- a/test/src/test/java/hudson/model/ApiSEC1704Test.java +++ b/test/src/test/java/hudson/model/ApiSEC1704Test.java @@ -31,7 +31,7 @@ import org.jvnet.hudson.test.TestExtension; import org.kohsuke.stapler.export.ExportedBean; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import static org.hamcrest.Matchers.equalTo; import static org.junit.Assert.assertThat; diff --git a/test/src/test/java/hudson/model/DescriptorVisibilityFilterTest.java b/test/src/test/java/hudson/model/DescriptorVisibilityFilterTest.java index 02b44c3b0de3..809a41c1ce1f 100644 --- a/test/src/test/java/hudson/model/DescriptorVisibilityFilterTest.java +++ b/test/src/test/java/hudson/model/DescriptorVisibilityFilterTest.java @@ -18,8 +18,8 @@ import org.jvnet.hudson.test.LoggerRule; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.Collection; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -66,7 +66,7 @@ public static final class TestSecurityRealm extends SecurityRealm { @TestExtension public static final class DescriptorImpl extends Descriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return "TestSecurityRealm"; @@ -76,7 +76,7 @@ public String getDisplayName() { @TestExtension public static final class HideDescriptor extends DescriptorVisibilityFilter { @Override - public boolean filter(@CheckForNull Object context, @Nonnull Descriptor descriptor) { + public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) { return !(descriptor instanceof DescriptorImpl); } } @@ -84,17 +84,17 @@ public boolean filter(@CheckForNull Object context, @Nonnull Descriptor descript public static final class TestAuthStrategy extends AuthorizationStrategy { - @Nonnull + @NonNull @Override public ACL getRootACL() { return null; } - @Nonnull + @NonNull @Override public Collection getGroups() { return null; } @TestExtension public static final class DescriptorImpl extends Descriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return "TestAuthStrategy"; @@ -104,7 +104,7 @@ public String getDisplayName() { @TestExtension public static final class HideDescriptor extends DescriptorVisibilityFilter { @Override - public boolean filter(@CheckForNull Object context, @Nonnull Descriptor descriptor) { + public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) { return !(descriptor instanceof DescriptorImpl); } } diff --git a/test/src/test/java/hudson/model/FingerprintTest.java b/test/src/test/java/hudson/model/FingerprintTest.java index 6e503d23d27b..be0a71ff3a2f 100644 --- a/test/src/test/java/hudson/model/FingerprintTest.java +++ b/test/src/test/java/hudson/model/FingerprintTest.java @@ -41,8 +41,8 @@ import java.util.Hashtable; import java.util.Map; import java.util.Set; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import jenkins.model.Jenkins; import org.junit.Rule; import org.junit.Test; @@ -295,8 +295,8 @@ public void adminShouldBeAbleToSeeReferencesOfDeletedJobs() throws Exception { } } - @Nonnull - private Fingerprint getFingerprint(@CheckForNull Run run, @Nonnull String filename) { + @NonNull + private Fingerprint getFingerprint(@CheckForNull Run run, @NonNull String filename) { assertNotNull("Input run is null", run); Fingerprinter.FingerprintAction action = run.getAction(Fingerprinter.FingerprintAction.class); assertNotNull("Fingerprint action has not been created in " + run, action); @@ -306,13 +306,13 @@ private Fingerprint getFingerprint(@CheckForNull Run run, @Nonnull String return fp; } - @Nonnull + @NonNull private FreeStyleProject createAndRunProjectWithPublisher(String projectName, String fpFileName) throws Exception { return createAndRunProjectWithPublisher(null, projectName, fpFileName); } - @Nonnull + @NonNull private FreeStyleProject createAndRunProjectWithPublisher(@CheckForNull MockFolder folder, String projectName, String fpFileName) throws Exception { final FreeStyleProject project; @@ -329,11 +329,11 @@ private FreeStyleProject createAndRunProjectWithPublisher(@CheckForNull MockFold return project; } - private void setupProjectMatrixAuthStrategy(@Nonnull Permission ... permissions) { + private void setupProjectMatrixAuthStrategy(@NonNull Permission ... permissions) { setupProjectMatrixAuthStrategy(true, permissions); } - private void setupProjectMatrixAuthStrategy(boolean inheritFromFolders, @Nonnull Permission ... permissions) { + private void setupProjectMatrixAuthStrategy(boolean inheritFromFolders, @NonNull Permission ... permissions) { ProjectMatrixAuthorizationStrategy str = inheritFromFolders ? new ProjectMatrixAuthorizationStrategy() : new NoInheritanceProjectMatrixAuthorizationStrategy(); @@ -343,7 +343,7 @@ private void setupProjectMatrixAuthStrategy(boolean inheritFromFolders, @Nonnull rule.jenkins.setAuthorizationStrategy(str); } //TODO: could be reworked to support multiple assignments - private void setJobPermissionsOnce(Job job, String username, @Nonnull Permission ... s) + private void setJobPermissionsOnce(Job job, String username, @NonNull Permission ... s) throws IOException { assertThat("Cannot assign the property twice", job.getProperty(AuthorizationMatrixProperty.class), nullValue()); diff --git a/test/src/test/java/hudson/model/SlaveTest.java b/test/src/test/java/hudson/model/SlaveTest.java index 459c2ecfde25..e0ad3e7faa9e 100644 --- a/test/src/test/java/hudson/model/SlaveTest.java +++ b/test/src/test/java/hudson/model/SlaveTest.java @@ -43,8 +43,8 @@ import java.net.URLEncoder; import java.util.HashSet; import java.util.Set; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.apache.commons.io.IOUtils; import static org.hamcrest.Matchers.anyOf; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -153,7 +153,7 @@ public void shouldNotEscapeJnlpSlavesResources() throws Exception { assertJnlpJarUrlFails(slave, "./../foo/bar"); } - private void assertJnlpJarUrlFails(@Nonnull Slave slave, @Nonnull String url) throws Exception { + private void assertJnlpJarUrlFails(@NonNull Slave slave, @NonNull String url) throws Exception { // Raw access to API Slave.JnlpJar jnlpJar = slave.getComputer().getJnlpJars(url); try { @@ -165,7 +165,7 @@ private void assertJnlpJarUrlFails(@Nonnull Slave slave, @Nonnull String url) th fail("Expected the MalformedURLException for " + url); } - private void assertJnlpJarUrlIsAllowed(@Nonnull Slave slave, @Nonnull String url) throws Exception { + private void assertJnlpJarUrlIsAllowed(@NonNull Slave slave, @NonNull String url) throws Exception { // Raw access to API Slave.JnlpJar jnlpJar = slave.getComputer().getJnlpJars(url); assertNotNull(jnlpJar.getURL()); @@ -240,12 +240,12 @@ public static Set descriptors() { } @Override - public boolean filterType(@Nonnull Class contextClass, @Nonnull Descriptor descriptor) { + public boolean filterType(@NonNull Class contextClass, @NonNull Descriptor descriptor) { return !descriptors.contains(descriptor); } @Override - public boolean filter(@CheckForNull Object context, @Nonnull Descriptor descriptor) { + public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) { return !descriptors.contains(descriptor); } } diff --git a/test/src/test/java/hudson/scm/AbstractScmTagActionTest.java b/test/src/test/java/hudson/scm/AbstractScmTagActionTest.java index dfef9b6fdac5..a0b931d12a91 100644 --- a/test/src/test/java/hudson/scm/AbstractScmTagActionTest.java +++ b/test/src/test/java/hudson/scm/AbstractScmTagActionTest.java @@ -38,8 +38,8 @@ import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.JenkinsRule; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.File; import java.io.IOException; @@ -109,7 +109,7 @@ public ChangeLogParser createChangeLogParser() { } @Override - public void checkout(@Nonnull Run build, @Nonnull Launcher launcher, @Nonnull FilePath workspace, @Nonnull TaskListener listener, @CheckForNull File changelogFile, @CheckForNull SCMRevisionState baseline) throws IOException, InterruptedException { + public void checkout(@NonNull Run build, @NonNull Launcher launcher, @NonNull FilePath workspace, @NonNull TaskListener listener, @CheckForNull File changelogFile, @CheckForNull SCMRevisionState baseline) throws IOException, InterruptedException { build.addAction(new TooltipTagAction(build, desiredTooltip)); } } diff --git a/test/src/test/java/hudson/security/ACLTest.java b/test/src/test/java/hudson/security/ACLTest.java index 40401d371133..7243875fcd2b 100644 --- a/test/src/test/java/hudson/security/ACLTest.java +++ b/test/src/test/java/hudson/security/ACLTest.java @@ -44,7 +44,7 @@ import org.jvnet.hudson.test.MockAuthorizationStrategy; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; public class ACLTest { diff --git a/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmTest.java b/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmTest.java index d5debcadd56f..f2020854680b 100644 --- a/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmTest.java +++ b/test/src/test/java/hudson/security/HudsonPrivateSecurityRealmTest.java @@ -70,7 +70,7 @@ import org.jvnet.hudson.test.WithoutJenkins; import org.mindrot.jbcrypt.BCrypt; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; @For({UserSeedProperty.class, HudsonPrivateSecurityRealm.class}) public class HudsonPrivateSecurityRealmTest { @@ -424,12 +424,12 @@ public static class SpySecurityListenerImpl extends SecurityListener { private List createdUsers = new ArrayList(); @Override - protected void loggedIn(@Nonnull String username) { + protected void loggedIn(@NonNull String username) { loggedInUsernames.add(username); } @Override - protected void userCreated(@Nonnull String username) { createdUsers.add(username); } + protected void userCreated(@NonNull String username) { createdUsers.add(username); } } @Issue("SECURITY-786") diff --git a/test/src/test/java/hudson/security/TokenBasedRememberMeServices2Test.java b/test/src/test/java/hudson/security/TokenBasedRememberMeServices2Test.java index 7854ca7869d4..68d73189362d 100644 --- a/test/src/test/java/hudson/security/TokenBasedRememberMeServices2Test.java +++ b/test/src/test/java/hudson/security/TokenBasedRememberMeServices2Test.java @@ -34,7 +34,7 @@ import org.springframework.dao.DataAccessException; import test.security.realm.InMemorySecurityRealm; -import javax.annotation.concurrent.GuardedBy; +import net.jcip.annotations.GuardedBy; import java.util.concurrent.TimeUnit; import static org.hamcrest.Matchers.is; diff --git a/test/src/test/java/hudson/security/csrf/CrumbExclusionTest.java b/test/src/test/java/hudson/security/csrf/CrumbExclusionTest.java index 9941fe349b70..8b65163a931a 100644 --- a/test/src/test/java/hudson/security/csrf/CrumbExclusionTest.java +++ b/test/src/test/java/hudson/security/csrf/CrumbExclusionTest.java @@ -49,7 +49,7 @@ import org.jvnet.hudson.test.TestExtension; import org.kohsuke.stapler.verb.POST; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; diff --git a/test/src/test/java/hudson/slaves/CloudTest.java b/test/src/test/java/hudson/slaves/CloudTest.java index be699c2109c3..586144fa1ede 100644 --- a/test/src/test/java/hudson/slaves/CloudTest.java +++ b/test/src/test/java/hudson/slaves/CloudTest.java @@ -22,7 +22,7 @@ import org.jvnet.hudson.test.WithoutJenkins; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.util.Arrays; import java.util.Collection; @@ -98,7 +98,7 @@ public static final class CloudActionFactory extends TransientActionFactory createFor(@Nonnull Cloud target) { + @NonNull @Override public Collection createFor(@NonNull Cloud target) { return Arrays.asList(new TaskCloudAction(), new ReportingCloudAction()); } } diff --git a/test/src/test/java/hudson/tasks/BuildTriggerTest.java b/test/src/test/java/hudson/tasks/BuildTriggerTest.java index a4cc55cf7c24..8a78e2900622 100644 --- a/test/src/test/java/hudson/tasks/BuildTriggerTest.java +++ b/test/src/test/java/hudson/tasks/BuildTriggerTest.java @@ -57,7 +57,7 @@ import java.util.Set; import java.util.List; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.model.Jenkins; import jenkins.security.QueueItemAuthenticatorConfiguration; diff --git a/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java b/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java index 75f41e5d6e39..a22cc2714008 100644 --- a/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java +++ b/test/src/test/java/hudson/tools/ZipExtractionInstallerTest.java @@ -42,8 +42,8 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.MockAuthorizationStrategy; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import java.lang.reflect.Field; import java.net.HttpURLConnection; import java.net.URL; @@ -166,7 +166,7 @@ public Object callFunction(HtmlPage page, Function function, Scriptable scope, S return super.callFunction(page, function, scope, thisObject, args); } - @Nonnull + @NonNull public XMLHttpRequest getLastRequest() { if (storedRequests.isEmpty()) { fail("There is no available requests for the proposed url/method"); diff --git a/test/src/test/java/jenkins/AgentProtocolTest.java b/test/src/test/java/jenkins/AgentProtocolTest.java index 2a407df8d3fd..c8b5d7f07939 100644 --- a/test/src/test/java/jenkins/AgentProtocolTest.java +++ b/test/src/test/java/jenkins/AgentProtocolTest.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import jenkins.model.Jenkins; import org.apache.commons.lang.StringUtils; import static org.junit.Assert.fail; diff --git a/test/src/test/java/jenkins/model/JenkinsTest.java b/test/src/test/java/jenkins/model/JenkinsTest.java index 2678ea3fe958..ae389ab4e278 100644 --- a/test/src/test/java/jenkins/model/JenkinsTest.java +++ b/test/src/test/java/jenkins/model/JenkinsTest.java @@ -85,7 +85,7 @@ import org.jvnet.hudson.test.MockAuthorizationStrategy; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * Tests of the {@link Jenkins} class instance logic. diff --git a/test/src/test/java/jenkins/model/TransientActionFactoryTest.java b/test/src/test/java/jenkins/model/TransientActionFactoryTest.java index 9e03a37d4aa5..b4b32817640d 100644 --- a/test/src/test/java/jenkins/model/TransientActionFactoryTest.java +++ b/test/src/test/java/jenkins/model/TransientActionFactoryTest.java @@ -49,7 +49,7 @@ import org.jvnet.hudson.test.MockFolder; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasSize; @@ -178,9 +178,9 @@ public Class type() { return Actionable.class; } - @Nonnull + @NonNull @Override - public Collection createFor(@Nonnull Actionable target) { + public Collection createFor(@NonNull Actionable target) { return Collections.singleton(new MyProminentProjectAction()); } } diff --git a/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java b/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java index ce0624c5bbcb..7226f272425f 100644 --- a/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java +++ b/test/src/test/java/jenkins/security/ApiTokenPropertyTest.java @@ -43,7 +43,7 @@ import java.util.concurrent.Callable; import java.util.function.Predicate; import java.util.stream.Collectors; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.recipes.LocalData; @@ -175,7 +175,7 @@ public void postWithUsernameAndTokenInBasicAuthHeader() throws Exception { assertEquals("foo", triggeredBy.getUserId()); } - @Nonnull + @NonNull private WebClient createClientForUser(final String id) throws Exception { User u = User.getById(id, true); diff --git a/test/src/test/java/jenkins/security/ResourceDomainTest.java b/test/src/test/java/jenkins/security/ResourceDomainTest.java index 5c5c335eb229..1d5aff797733 100644 --- a/test/src/test/java/jenkins/security/ResourceDomainTest.java +++ b/test/src/test/java/jenkins/security/ResourceDomainTest.java @@ -23,7 +23,7 @@ import org.jvnet.hudson.test.TestExtension; import org.kohsuke.stapler.HttpResponse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.net.URL; import java.time.Instant; import java.util.UUID; diff --git a/test/src/test/java/jenkins/security/SpySecurityListener.java b/test/src/test/java/jenkins/security/SpySecurityListener.java index 0d9731cc9091..59367a9074be 100644 --- a/test/src/test/java/jenkins/security/SpySecurityListener.java +++ b/test/src/test/java/jenkins/security/SpySecurityListener.java @@ -25,7 +25,7 @@ import org.acegisecurity.userdetails.UserDetails; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; @@ -56,27 +56,27 @@ public void clearPreviousCalls(){ } @Override - protected void authenticated(@Nonnull UserDetails details) { + protected void authenticated(@NonNull UserDetails details) { this.authenticatedCalls.add(details); } @Override - protected void failedToAuthenticate(@Nonnull String username) { + protected void failedToAuthenticate(@NonNull String username) { this.failedToAuthenticateCalls.add(username); } @Override - protected void loggedIn(@Nonnull String username) { + protected void loggedIn(@NonNull String username) { this.loggedInCalls.add(username); } @Override - protected void failedToLogIn(@Nonnull String username) { + protected void failedToLogIn(@NonNull String username) { this.failedToLogInCalls.add(username); } @Override - protected void loggedOut(@Nonnull String username) { + protected void loggedOut(@NonNull String username) { this.loggedOutCalls.add(username); } diff --git a/test/src/test/java/jenkins/security/SuspiciousRequestFilterTest.java b/test/src/test/java/jenkins/security/SuspiciousRequestFilterTest.java index 480dd1d8242c..45a5388895ab 100644 --- a/test/src/test/java/jenkins/security/SuspiciousRequestFilterTest.java +++ b/test/src/test/java/jenkins/security/SuspiciousRequestFilterTest.java @@ -12,7 +12,7 @@ import org.kohsuke.stapler.QueryParameter; import org.kohsuke.stapler.verb.GET; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.http.HttpServletResponse; import java.net.URL; diff --git a/test/src/test/java/jenkins/security/seed/UserSeedChangeListenerTest.java b/test/src/test/java/jenkins/security/seed/UserSeedChangeListenerTest.java index 934463790ef8..5ff9f4d77175 100644 --- a/test/src/test/java/jenkins/security/seed/UserSeedChangeListenerTest.java +++ b/test/src/test/java/jenkins/security/seed/UserSeedChangeListenerTest.java @@ -31,7 +31,7 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.net.URL; @@ -88,7 +88,7 @@ public static class TestUserSeedChangeListener extends UserSeedChangeListener { boolean userWasNull; @Override - public void onUserSeedRenewed(@Nonnull User user) { + public void onUserSeedRenewed(@NonNull User user) { if (user == null) { userWasNull = true; } diff --git a/test/src/test/java/jenkins/security/stapler/CustomRoutingDecisionProviderTest.java b/test/src/test/java/jenkins/security/stapler/CustomRoutingDecisionProviderTest.java index aef0510fbbf8..750ddb28bcc8 100644 --- a/test/src/test/java/jenkins/security/stapler/CustomRoutingDecisionProviderTest.java +++ b/test/src/test/java/jenkins/security/stapler/CustomRoutingDecisionProviderTest.java @@ -35,8 +35,8 @@ import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.WebMethod; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import static org.hamcrest.CoreMatchers.is; @@ -52,7 +52,7 @@ public class CustomRoutingDecisionProviderTest { @TestExtension("customRoutingWhitelistProvider") public static class XxxBlacklister extends RoutingDecisionProvider { @Override - public Decision decide(@Nonnull String signature) { + public Decision decide(@NonNull String signature) { if (signature.contains("xxx")) { return Decision.REJECTED; } diff --git a/test/src/test/java/jenkins/security/stapler/DynamicTest.java b/test/src/test/java/jenkins/security/stapler/DynamicTest.java index 519f460d1c62..75f8d97ae49e 100644 --- a/test/src/test/java/jenkins/security/stapler/DynamicTest.java +++ b/test/src/test/java/jenkins/security/stapler/DynamicTest.java @@ -13,7 +13,7 @@ import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.util.stream.Stream; @Issue("SECURITY-400") diff --git a/test/src/test/java/jenkins/security/stapler/PreventRoutingTest.java b/test/src/test/java/jenkins/security/stapler/PreventRoutingTest.java index b8c11cada8fb..bc5d70c08a6d 100644 --- a/test/src/test/java/jenkins/security/stapler/PreventRoutingTest.java +++ b/test/src/test/java/jenkins/security/stapler/PreventRoutingTest.java @@ -32,8 +32,8 @@ import org.kohsuke.stapler.StaplerProxy; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.List; public class PreventRoutingTest extends StaplerAbstractTest { @@ -102,7 +102,7 @@ public Renderable getLegitRoutable2(){ } } - private static void notStaplerGetter(@Nonnull Object o){ + private static void notStaplerGetter(@NonNull Object o){ StaplerRequest req = Stapler.getCurrentRequest(); if (req != null) { List ancestors = req.getAncestors(); diff --git a/test/src/test/java/jenkins/security/stapler/Security867Test.java b/test/src/test/java/jenkins/security/stapler/Security867Test.java index bae57b906a0b..8d87df5c5aea 100644 --- a/test/src/test/java/jenkins/security/stapler/Security867Test.java +++ b/test/src/test/java/jenkins/security/stapler/Security867Test.java @@ -31,7 +31,7 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.containsString; diff --git a/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java b/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java index ccc40a4f37fa..b7ca0ebd05d4 100644 --- a/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java +++ b/test/src/test/java/jenkins/security/stapler/StaplerAbstractTest.java @@ -37,7 +37,7 @@ import org.kohsuke.stapler.WebApp; import org.kohsuke.stapler.WebMethod; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.awt.*; import java.io.IOException; import java.net.URL; diff --git a/test/src/test/java/jenkins/security/stapler/StaplerDispatchValidatorTest.java b/test/src/test/java/jenkins/security/stapler/StaplerDispatchValidatorTest.java index 4c71fd7cb476..421e5d50f190 100644 --- a/test/src/test/java/jenkins/security/stapler/StaplerDispatchValidatorTest.java +++ b/test/src/test/java/jenkins/security/stapler/StaplerDispatchValidatorTest.java @@ -34,7 +34,7 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.io.InputStream; import java.net.HttpURLConnection; import java.util.Locale; diff --git a/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java b/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java index 3ffde5969862..8180ff846dec 100644 --- a/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java +++ b/test/src/test/java/jenkins/security/stapler/StaticRoutingDecisionProviderTest.java @@ -34,7 +34,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.WebMethod; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.Method; diff --git a/test/src/test/java/jenkins/telemetry/MissingClassTelemetryTest.java b/test/src/test/java/jenkins/telemetry/MissingClassTelemetryTest.java index a2574c2059ae..5e01b2debe3c 100644 --- a/test/src/test/java/jenkins/telemetry/MissingClassTelemetryTest.java +++ b/test/src/test/java/jenkins/telemetry/MissingClassTelemetryTest.java @@ -40,7 +40,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; diff --git a/test/src/test/java/jenkins/telemetry/TelemetryTest.java b/test/src/test/java/jenkins/telemetry/TelemetryTest.java index ea53cd9e78e4..0910b08db81e 100644 --- a/test/src/test/java/jenkins/telemetry/TelemetryTest.java +++ b/test/src/test/java/jenkins/telemetry/TelemetryTest.java @@ -18,8 +18,8 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.FilterChain; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; @@ -94,25 +94,25 @@ public void testPerTrialCorrelator() throws Exception { @TestExtension public static class EmptyTelemetry extends Telemetry { - @Nonnull + @NonNull @Override public String getDisplayName() { return "empty"; } - @Nonnull + @NonNull @Override public String getId() { return "empty"; } - @Nonnull + @NonNull @Override public LocalDate getStart() { return LocalDate.MIN; } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return LocalDate.MAX; @@ -127,31 +127,31 @@ public JSONObject createContent() { @TestExtension public static class DisabledFutureTelemetry extends Telemetry { - @Nonnull + @NonNull @Override public String getId() { return "future"; } - @Nonnull + @NonNull @Override public String getDisplayName() { return "future"; } - @Nonnull + @NonNull @Override public LocalDate getStart() { return LocalDate.now().plus(1, ChronoUnit.DAYS); } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return LocalDate.MAX; } - @Nonnull + @NonNull @Override public JSONObject createContent() { return new JSONObject(); @@ -161,31 +161,31 @@ public JSONObject createContent() { @TestExtension public static class DisabledPastTelemetry extends Telemetry { - @Nonnull + @NonNull @Override public String getId() { return "past"; } - @Nonnull + @NonNull @Override public String getDisplayName() { return "past"; } - @Nonnull + @NonNull @Override public LocalDate getStart() { return LocalDate.MIN; } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return LocalDate.now().minus(1, ChronoUnit.DAYS); } - @Nonnull + @NonNull @Override public JSONObject createContent() { return new JSONObject(); @@ -195,31 +195,31 @@ public JSONObject createContent() { @TestExtension public static class TestTelemetry extends Telemetry { - @Nonnull + @NonNull @Override public String getId() { return "test-data"; } - @Nonnull + @NonNull @Override public String getDisplayName() { return "test-data"; } - @Nonnull + @NonNull @Override public LocalDate getStart() { return LocalDate.MIN; } - @Nonnull + @NonNull @Override public LocalDate getEnd() { return LocalDate.MAX; } - @Nonnull + @NonNull @Override public JSONObject createContent() { return new JSONObject(); diff --git a/test/src/test/java/jenkins/triggers/TriggerTest.java b/test/src/test/java/jenkins/triggers/TriggerTest.java index b76dd379b313..1c0d30c3fb7b 100644 --- a/test/src/test/java/jenkins/triggers/TriggerTest.java +++ b/test/src/test/java/jenkins/triggers/TriggerTest.java @@ -15,7 +15,7 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.LoggerRule; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import java.util.logging.Level; import java.util.logging.Logger; @@ -53,7 +53,7 @@ public static class BadTimerTrigger extends TimerTrigger { private static final Logger LOGGER = Logger.getLogger(BadTimerTrigger.class.getName()); - BadTimerTrigger(@Nonnull final String specs) throws ANTLRException { + BadTimerTrigger(@NonNull final String specs) throws ANTLRException { super(specs); } diff --git a/test/src/test/java/lib/form/ExpandableTextboxTest.java b/test/src/test/java/lib/form/ExpandableTextboxTest.java index 02d39f3fd512..a4c210d8bee7 100644 --- a/test/src/test/java/lib/form/ExpandableTextboxTest.java +++ b/test/src/test/java/lib/form/ExpandableTextboxTest.java @@ -47,7 +47,7 @@ import org.kohsuke.stapler.WebMethod; import org.w3c.dom.NodeList; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; /** * @author Kohsuke Kawaguchi diff --git a/test/src/test/java/lib/form/ValidateButtonTest.java b/test/src/test/java/lib/form/ValidateButtonTest.java index a9a358986fcb..281c13017ced 100644 --- a/test/src/test/java/lib/form/ValidateButtonTest.java +++ b/test/src/test/java/lib/form/ValidateButtonTest.java @@ -41,7 +41,7 @@ import com.gargoylesoftware.htmlunit.html.HtmlPage; import org.kohsuke.stapler.StaplerRequest; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; diff --git a/test/src/test/java/lib/layout/ConfirmationLinkTest.java b/test/src/test/java/lib/layout/ConfirmationLinkTest.java index 0db6bad04e0c..34f9ff3e1bbb 100644 --- a/test/src/test/java/lib/layout/ConfirmationLinkTest.java +++ b/test/src/test/java/lib/layout/ConfirmationLinkTest.java @@ -39,7 +39,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.WebMethod; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import java.net.HttpURLConnection; diff --git a/test/src/test/java/lib/layout/StopButtonTest.java b/test/src/test/java/lib/layout/StopButtonTest.java index b4f8950e7a53..626fa3efc655 100644 --- a/test/src/test/java/lib/layout/StopButtonTest.java +++ b/test/src/test/java/lib/layout/StopButtonTest.java @@ -38,7 +38,7 @@ import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.WebMethod; -import javax.annotation.CheckForNull; +import edu.umd.cs.findbugs.annotations.CheckForNull; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; diff --git a/test/src/test/java/org/kohsuke/stapler/MockStaplerRequestBuilder.java b/test/src/test/java/org/kohsuke/stapler/MockStaplerRequestBuilder.java index 6d58f2250ca2..c639e9146bc9 100644 --- a/test/src/test/java/org/kohsuke/stapler/MockStaplerRequestBuilder.java +++ b/test/src/test/java/org/kohsuke/stapler/MockStaplerRequestBuilder.java @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.annotation.Nonnull; +import edu.umd.cs.findbugs.annotations.NonNull; import javax.servlet.http.HttpServletRequest; import org.jvnet.hudson.test.JenkinsRule; import org.mockito.Mockito; @@ -45,7 +45,7 @@ public class MockStaplerRequestBuilder{ final Map getters = new HashMap<>(); private Stapler stapler; - public MockStaplerRequestBuilder(@Nonnull JenkinsRule r, String url) { + public MockStaplerRequestBuilder(@NonNull JenkinsRule r, String url) { this.r = r; this.tokens = new TokenList(url); } diff --git a/war/pom.xml b/war/pom.xml index 2b5e49dc3c02..795134d81ed5 100644 --- a/war/pom.xml +++ b/war/pom.xml @@ -1,4 +1,3 @@ -