Skip to content

Commit

Permalink
Suppress ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD SpotBugs violations (
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored Dec 29, 2021
1 parent 47b5700 commit 8a8c70f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/hudson/slaves/SlaveComputer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1047,6 +1048,7 @@ private static class SlaveInitializer extends MasterToSlaveCallable<Void,Runtime
}

@Override
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "field is static for the reason explained in the Javadoc for LogHolder")
public Void call() {
SLAVE_LOG_HANDLER = new RingBufferLogHandler(ringBufferSize);

Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/hudson/tasks/ArtifactArchiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ public BuildStepMonitor getRequiredMonitorService() {

@Extension @Symbol("archiveArtifacts")
public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "for backward compatibility")
public DescriptorImpl() {
DESCRIPTOR = this; // backward compatibility
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/jenkins/security/UserDetailsCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/jenkins/slaves/NioChannelSelector.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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) {
Expand Down
10 changes: 0 additions & 10 deletions src/spotbugs/spotbugs-excludes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -368,16 +368,6 @@
<Class name="jenkins.security.CryptoConfidentialKey"/>
</Or>
</And>
<And>
<Bug pattern="ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD"/>
<Or>
<Class name="hudson.slaves.SlaveComputer$SlaveInitializer"/>
<Class name="hudson.tasks.ArtifactArchiver$DescriptorImpl"/>
<Class name="jenkins.security.QueueItemAuthenticatorMonitor"/>
<Class name="jenkins.security.UserDetailsCache"/>
<Class name="jenkins.slaves.NioChannelSelector"/>
</Or>
</And>
<And>
<Bug pattern="UG_SYNC_SET_UNSYNC_GET"/>
<Or>
Expand Down

0 comments on commit 8a8c70f

Please sign in to comment.