From 8a8c70f04fae8a232856f9c66e495fff7848516c Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Wed, 29 Dec 2021 08:00:45 -0800 Subject: [PATCH] Suppress `ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD` SpotBugs violations (#6123) --- core/src/main/java/hudson/slaves/SlaveComputer.java | 2 ++ core/src/main/java/hudson/tasks/ArtifactArchiver.java | 1 + .../security/QueueItemAuthenticatorMonitor.java | 2 ++ .../main/java/jenkins/security/UserDetailsCache.java | 2 ++ .../main/java/jenkins/slaves/NioChannelSelector.java | 2 ++ src/spotbugs/spotbugs-excludes.xml | 10 ---------- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/hudson/slaves/SlaveComputer.java b/core/src/main/java/hudson/slaves/SlaveComputer.java index d0c79fae61a4..b5dc5eaff3e9 100644 --- a/core/src/main/java/hudson/slaves/SlaveComputer.java +++ b/core/src/main/java/hudson/slaves/SlaveComputer.java @@ -29,6 +29,7 @@ import edu.umd.cs.findbugs.annotations.CheckReturnValue; import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.OverrideMustInvoke; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.AbortException; import hudson.FilePath; import hudson.Functions; @@ -1047,6 +1048,7 @@ private static class SlaveInitializer extends MasterToSlaveCallable { + @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "for backward compatibility") public DescriptorImpl() { DESCRIPTOR = this; // backward compatibility } diff --git a/core/src/main/java/jenkins/security/QueueItemAuthenticatorMonitor.java b/core/src/main/java/jenkins/security/QueueItemAuthenticatorMonitor.java index f1e6599cc79e..d2a8e25defe9 100644 --- a/core/src/main/java/jenkins/security/QueueItemAuthenticatorMonitor.java +++ b/core/src/main/java/jenkins/security/QueueItemAuthenticatorMonitor.java @@ -23,6 +23,7 @@ */ package jenkins.security; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.Extension; import hudson.model.AdministrativeMonitor; import hudson.model.Job; @@ -72,6 +73,7 @@ public boolean isSecurity() { } @RequirePOST + @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "field is static so that it can be written to by the static QueueListenerImpl class") public HttpResponse doAct(@QueryParameter String redirect, @QueryParameter String dismiss, @QueryParameter String reset) throws IOException { if (redirect != null) { return HttpResponses.redirectTo("https://www.jenkins.io/redirect/queue-item-security"); diff --git a/core/src/main/java/jenkins/security/UserDetailsCache.java b/core/src/main/java/jenkins/security/UserDetailsCache.java index 76c13c2c98d5..b03f5c0da5e3 100644 --- a/core/src/main/java/jenkins/security/UserDetailsCache.java +++ b/core/src/main/java/jenkins/security/UserDetailsCache.java @@ -28,6 +28,7 @@ import com.google.common.util.concurrent.UncheckedExecutionException; import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.Extension; import hudson.ExtensionList; import hudson.security.UserMayOrMayNotExistException2; @@ -61,6 +62,7 @@ public final class UserDetailsCache { * Constructor intended to be instantiated by Jenkins only. */ @Restricted(NoExternalUse.class) + @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "field is static for script console") public UserDetailsCache() { if (EXPIRE_AFTER_WRITE_SEC == null || EXPIRE_AFTER_WRITE_SEC <= 0) { //just in case someone is trying to trick us diff --git a/core/src/main/java/jenkins/slaves/NioChannelSelector.java b/core/src/main/java/jenkins/slaves/NioChannelSelector.java index 80cda778c44c..423cd658f31b 100644 --- a/core/src/main/java/jenkins/slaves/NioChannelSelector.java +++ b/core/src/main/java/jenkins/slaves/NioChannelSelector.java @@ -1,5 +1,6 @@ package jenkins.slaves; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.Extension; import hudson.init.Terminator; import hudson.model.Computer; @@ -18,6 +19,7 @@ public class NioChannelSelector { private NioChannelHub hub; + @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "field is static for script console") public NioChannelSelector() { try { if (!DISABLED) { diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index 336890630961..b08e519512f3 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -368,16 +368,6 @@ - - - - - - - - - -