From 6cdc97e0081276470bb96535e65bd0b4cb195ec9 Mon Sep 17 00:00:00 2001 From: Mark Waite Date: Sat, 16 Mar 2019 18:43:25 -0600 Subject: [PATCH] Suppress more spotbugs warnings Java 11 specific, but not worth the distraction of spotbugs reporting spurious warnings. Easier to suppress the warnings than remember that they can be ignored. --- .../java/jenkins/plugins/git/AbstractGitSCMSource.java | 9 +++++---- src/main/java/jenkins/plugins/git/GitSCMFile.java | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java b/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java index d4bf1e964d..262fd36bb5 100644 --- a/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java +++ b/src/main/java/jenkins/plugins/git/AbstractGitSCMSource.java @@ -1466,6 +1466,11 @@ public boolean isApplicable(java.lang.Class job) { * * @since 3.6.1 */ + @SuppressFBWarnings(value = { "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE", + "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", + "NP_LOAD_OF_KNOWN_NULL_VALUE" + }, + justification = "Java 11 generated code causes redundant nullcheck") private static class TreeWalkingSCMProbe extends SCMProbe { private final String name; private final long lastModified; @@ -1508,10 +1513,6 @@ public long lastModified() { */ @Override @NonNull - @SuppressFBWarnings(value = "NP_LOAD_OF_KNOWN_NULL_VALUE", - justification = - "TreeWalk.forPath can return null, compiler " - + "generated code for try with resources handles it") public SCMProbeStat stat(@NonNull String path) throws IOException { try (TreeWalk tw = TreeWalk.forPath(repository, path, tree)) { if (tw == null) { diff --git a/src/main/java/jenkins/plugins/git/GitSCMFile.java b/src/main/java/jenkins/plugins/git/GitSCMFile.java index 9c571224b6..9131f51920 100644 --- a/src/main/java/jenkins/plugins/git/GitSCMFile.java +++ b/src/main/java/jenkins/plugins/git/GitSCMFile.java @@ -26,6 +26,7 @@ package jenkins.plugins.git; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.ByteArrayInputStream; import java.io.FileNotFoundException; import java.io.IOException; @@ -48,6 +49,11 @@ * * @since 3.0.2 */ +@SuppressFBWarnings(value = { "RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE", + "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE", + "NP_LOAD_OF_KNOWN_NULL_VALUE" + }, + justification = "Java 11 generated code causes redundant nullcheck") public class GitSCMFile extends SCMFile { private final GitSCMFileSystem fs;