diff --git a/cli/src/main/java/hudson/cli/CLI.java b/cli/src/main/java/hudson/cli/CLI.java index bffbb5705a..05e52a6d25 100644 --- a/cli/src/main/java/hudson/cli/CLI.java +++ b/cli/src/main/java/hudson/cli/CLI.java @@ -261,7 +261,7 @@ public class CLI { } if(args.isEmpty()) - args = Arrays.asList("help"); // default to help + args = Collections.singletonList("help"); // default to help if (mode == null) { mode = Mode.HTTP; diff --git a/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java b/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java index ebdd18a192..0850bcb7bf 100644 --- a/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java +++ b/cli/src/main/java/hudson/cli/FlightRecorderInputStream.java @@ -1,5 +1,7 @@ package hudson.cli; +import edu.umd.cs.findbugs.annotations.NonNull; + import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -92,7 +94,7 @@ class FlightRecorderInputStream extends InputStream { } @Override - public int read(byte[] b, int off, int len) throws IOException { + public int read(@NonNull byte[] b, int off, int len) throws IOException { len = source.read(b, off, len); if (len>0) recorder.write(b,off,len); @@ -157,7 +159,7 @@ class FlightRecorderInputStream extends InputStream { } /** @author @roadrunner2 */ - @Override public synchronized void write(byte[] buf, int off, int len) { + @Override public synchronized void write(@NonNull byte[] buf, int off, int len) { // no point in trying to copy more than capacity; this also simplifies logic below if (len > capacity) { off += (len - capacity); diff --git a/cli/src/main/java/hudson/cli/PlainCLIProtocol.java b/cli/src/main/java/hudson/cli/PlainCLIProtocol.java index 5359b7c738..7018d4770c 100644 --- a/cli/src/main/java/hudson/cli/PlainCLIProtocol.java +++ b/cli/src/main/java/hudson/cli/PlainCLIProtocol.java @@ -36,6 +36,8 @@ import java.nio.channels.ClosedChannelException; import java.nio.channels.ReadPendingException; import java.util.logging.Level; import java.util.logging.Logger; + +import edu.umd.cs.findbugs.annotations.NonNull; import org.apache.commons.io.IOUtils; import org.apache.commons.io.input.BoundedInputStream; import org.apache.commons.io.input.CountingInputStream; @@ -233,11 +235,11 @@ class PlainCLIProtocol { send(op, new byte[] {(byte) b}); } @Override - public void write(byte[] b, int off, int len) throws IOException { + public void write(@NonNull byte[] b, int off, int len) throws IOException { send(op, b, off, len); } @Override - public void write(byte[] b) throws IOException { + public void write(@NonNull byte[] b) throws IOException { send(op, b); } }; diff --git a/cli/src/main/java/hudson/cli/PrivateKeyProvider.java b/cli/src/main/java/hudson/cli/PrivateKeyProvider.java index fbd4f332da..579aae6e53 100644 --- a/cli/src/main/java/hudson/cli/PrivateKeyProvider.java +++ b/cli/src/main/java/hudson/cli/PrivateKeyProvider.java @@ -52,7 +52,7 @@ import org.apache.sshd.common.util.security.SecurityUtils; */ public class PrivateKeyProvider { - private List privateKeys = new ArrayList(); + private List privateKeys = new ArrayList<>(); /** * Get keys read so far. diff --git a/cli/src/main/java/hudson/util/QuotedStringTokenizer.java b/cli/src/main/java/hudson/util/QuotedStringTokenizer.java index 55db964b09..6a82382d26 100644 --- a/cli/src/main/java/hudson/util/QuotedStringTokenizer.java +++ b/cli/src/main/java/hudson/util/QuotedStringTokenizer.java @@ -129,7 +129,7 @@ public class QuotedStringTokenizer } public String[] toArray() { - List r = new ArrayList(); + List r = new ArrayList<>(); while(hasMoreTokens()) r.add(nextToken()); return r.toArray(new String[r.size()]); diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index bfac3b9728..49f4dd6c0a 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -2196,11 +2196,7 @@ public class Functions { public static ArrayList getCLICommands() { ArrayList all = new ArrayList<>(CLICommand.all()); - Collections.sort(all, new Comparator() { - public int compare(CLICommand cliCommand, CLICommand cliCommand1) { - return cliCommand.getName().compareTo(cliCommand1.getName()); - } - }); + all.sort(Comparator.comparing(CLICommand::getName)); return all; } diff --git a/core/src/main/java/hudson/PluginWrapper.java b/core/src/main/java/hudson/PluginWrapper.java index 0442248c2d..2a94146694 100644 --- a/core/src/main/java/hudson/PluginWrapper.java +++ b/core/src/main/java/hudson/PluginWrapper.java @@ -221,7 +221,7 @@ public class PluginWrapper implements Comparable, ModelObject { * The core can depend on a plugin if it is bundled. Sometimes it's the only thing that * depends on the plugin e.g. UI support library bundle plugin. */ - private static Set CORE_ONLY_DEPENDANT = ImmutableSet.copyOf(Arrays.asList("jenkins-core")); + private static Set CORE_ONLY_DEPENDANT = ImmutableSet.copyOf(Collections.singletonList("jenkins-core")); /** * Set the list of components that depend on this plugin. diff --git a/core/src/main/java/hudson/model/Actionable.java b/core/src/main/java/hudson/model/Actionable.java index 17c5fa3b8e..e513897a8c 100644 --- a/core/src/main/java/hudson/model/Actionable.java +++ b/core/src/main/java/hudson/model/Actionable.java @@ -146,7 +146,7 @@ public abstract class Actionable extends AbstractModelObject implements ModelObj * Note: calls to {@link #getAllActions()} that happen before calls to this method may not see the update. * Note: this method will always modify the actions */ - @SuppressWarnings({"ConstantConditions","deprecation"}) + @SuppressWarnings({"ConstantConditions"}) @SuppressFBWarnings("RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE") public void addAction(@NonNull Action a) { if(a==null) { diff --git a/core/src/main/java/hudson/security/csrf/CrumbFilter.java b/core/src/main/java/hudson/security/csrf/CrumbFilter.java index 8d28351240..c8a0f80b61 100644 --- a/core/src/main/java/hudson/security/csrf/CrumbFilter.java +++ b/core/src/main/java/hudson/security/csrf/CrumbFilter.java @@ -77,7 +77,7 @@ public class CrumbFilter implements Filter { // Copied from Stapler#canonicalPath private static String canonicalPath(String path) { - List r = new ArrayList(Arrays.asList(path.split("/+"))); + List r = new ArrayList<>(Arrays.asList(path.split("/+"))); for (int i=0; i DEFAULT_ILLEGAL_FUNCTIONS = Collections.unmodifiableSet(new HashSet<>( - Arrays.asList("document") + Collections.singletonList("document") )); private final FunctionContext base; private final Set illegalFunctions; diff --git a/core/src/main/java/jenkins/util/xstream/XStreamDOM.java b/core/src/main/java/jenkins/util/xstream/XStreamDOM.java index b8aa7ef38c..2653325a23 100644 --- a/core/src/main/java/jenkins/util/xstream/XStreamDOM.java +++ b/core/src/main/java/jenkins/util/xstream/XStreamDOM.java @@ -307,9 +307,12 @@ public class XStreamDOM { if (node.children.get(i).tagName.equals(child.tagName)) count++; boolean more = false; - for (int i=pos; !more && i