From a0c843698df33013cb8c7e0c2322f80eba1f5504 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 16:20:52 -0800 Subject: [PATCH 01/12] Fix `SE_NO_SERIALVERSIONID` SpotBugs violations --- core/src/main/java/hudson/util/RemotingDiagnostics.java | 1 + .../jenkins/security/NonSerializableSecurityContext.java | 4 +++- src/spotbugs/spotbugs-excludes.xml | 7 ------- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/core/src/main/java/hudson/util/RemotingDiagnostics.java b/core/src/main/java/hudson/util/RemotingDiagnostics.java index 5c435ae0b0..0ae676035c 100644 --- a/core/src/main/java/hudson/util/RemotingDiagnostics.java +++ b/core/src/main/java/hudson/util/RemotingDiagnostics.java @@ -148,6 +148,7 @@ public final class RemotingDiagnostics { } return out.toString(); } + private static final long serialVersionUID = 1L; } /** diff --git a/core/src/main/java/jenkins/security/NonSerializableSecurityContext.java b/core/src/main/java/jenkins/security/NonSerializableSecurityContext.java index 4e47cb20ca..334948e7ce 100644 --- a/core/src/main/java/jenkins/security/NonSerializableSecurityContext.java +++ b/core/src/main/java/jenkins/security/NonSerializableSecurityContext.java @@ -42,7 +42,9 @@ import org.springframework.security.core.userdetails.UserDetails; * @see hudson.security.HttpSessionContextIntegrationFilter2 * @since 1.509 */ -@SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "It is not intended to be serialized. Default values will be used in case of deserialization") +@SuppressFBWarnings( + value = {"SE_NO_SERIALVERSIONID", "SE_TRANSIENT_FIELD_NOT_RESTORED"}, + justification = "It is not intended to be serialized. Default values will be used in case of deserialization") @Restricted(NoExternalUse.class) public class NonSerializableSecurityContext implements SecurityContext { private transient Authentication authentication; diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index 11df143247..793b48b9b3 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -648,13 +648,6 @@ - - - - - - - From d374369d408f26f4706a8379a9f164f781384bd9 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 16:23:15 -0800 Subject: [PATCH 02/12] Fix `OS_OPEN_STREAM` SpotBugs violations --- src/spotbugs/spotbugs-excludes.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index 793b48b9b3..149d06d233 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -418,13 +418,6 @@ - - - - - - - From 8c4ae1a14577d8836be62dbc051e0ee2ec1c87eb Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 16:30:45 -0800 Subject: [PATCH 03/12] Fix `CO_COMPARETO_INCORRECT_FLOATING` SpotBugs violations --- core/src/main/java/jenkins/FilePathFilterAggregator.java | 2 +- src/spotbugs/spotbugs-excludes.xml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/core/src/main/java/jenkins/FilePathFilterAggregator.java b/core/src/main/java/jenkins/FilePathFilterAggregator.java index 728700a775..0702bebb80 100644 --- a/core/src/main/java/jenkins/FilePathFilterAggregator.java +++ b/core/src/main/java/jenkins/FilePathFilterAggregator.java @@ -30,7 +30,7 @@ class FilePathFilterAggregator extends FilePathFilter { @Override public int compareTo(Entry that) { - double result = Double.compare(this.ordinal, that.ordinal); + int result = Double.compare(this.ordinal, that.ordinal); if (result < 0) return -1; if (result > 0) return 1; diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index 149d06d233..c9d1ed1fed 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -82,10 +82,6 @@ - - - - From 57abb105ff7d17fb1cd704d135557c1c5ebe0eb7 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 16:33:48 -0800 Subject: [PATCH 04/12] Fix `HARD_CODE_PASSWORD` SpotBugs violations --- .../java/hudson/security/AuthenticationProcessingFilter2.java | 2 ++ src/spotbugs/spotbugs-excludes.xml | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java b/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java index 55f3358adf..ecec5b9aea 100644 --- a/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java +++ b/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java @@ -23,6 +23,7 @@ */ package hudson.security; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.model.User; import java.io.IOException; import java.util.logging.Level; @@ -52,6 +53,7 @@ import org.springframework.security.web.util.matcher.AntPathRequestMatcher; @Restricted(NoExternalUse.class) public final class AuthenticationProcessingFilter2 extends UsernamePasswordAuthenticationFilter { + @SuppressFBWarnings(value = "HARD_CODE_PASSWORD", justification = "This is a password parameter, not a password") public AuthenticationProcessingFilter2(String authenticationGatewayUrl) { setRequiresAuthenticationRequestMatcher(new AntPathRequestMatcher("/" + authenticationGatewayUrl, "POST")); // Jenkins/login.jelly & SetupWizard/authenticate-security-token.jelly diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index c9d1ed1fed..4d3db8a2c9 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -180,10 +180,6 @@ - - - - From 4492a1c19881eb21f6f1e2a1ed5915fcf95a4873 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 16:40:25 -0800 Subject: [PATCH 05/12] Fix `NP_NULL_PARAM_DEREF` SpotBugs violations --- core/src/main/java/hudson/PluginManager.java | 3 ++- core/src/main/java/hudson/model/Run.java | 3 ++- src/spotbugs/spotbugs-excludes.xml | 7 ------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 9902dc3921..d067ed49fe 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -88,6 +88,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Optional; import java.util.ServiceLoader; import java.util.Set; @@ -647,7 +648,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } names.add(fileName); - copyBundledPlugin(url, fileName); + copyBundledPlugin(Objects.requireNonNull(url), fileName); copiedPlugins.add(url); try { addDependencies(url, fromPath, dependencies); diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index d72b24a668..e0918ef219 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -100,6 +100,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Locale; import java.util.Map; +import java.util.Objects; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -1911,7 +1912,7 @@ public abstract class Run ,RunT extends Run - - - - - - - From 081c0ce6f4dd71d700548bc7ec9891dfa365bad2 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 18:27:20 -0800 Subject: [PATCH 06/12] Fix `JLM_JSR166_UTILCONCURRENT_MONITORENTER` SpotBugs violations --- core/src/main/java/hudson/PluginManager.java | 4 +--- src/spotbugs/spotbugs-excludes.xml | 4 ---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index d067ed49fe..7dad538d6f 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -911,9 +911,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas plugins.add(p); if (p.isActive()) activePlugins.add(p); - synchronized (((UberClassLoader) uberClassLoader).loaded) { - ((UberClassLoader) uberClassLoader).loaded.clear(); - } + ((UberClassLoader) uberClassLoader).loaded.clear(); // TODO antimodular; perhaps should have a PluginListener to complement ExtensionListListener? CustomClassFilter.Contributed.load(); diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index ccd7c6f5c7..b825555ade 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -228,10 +228,6 @@ - - - - From 1a89cec44ef601ce490d023fab2b6527db0a7ec4 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 18:34:13 -0800 Subject: [PATCH 07/12] Fix `SR_NOT_CHECKED` SpotBugs violations --- src/spotbugs/spotbugs-excludes.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index b825555ade..b6ebac958d 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -635,10 +635,6 @@ - - - - From 2023494b86f11f7ebbc863b4a53b0305efe6e3d6 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 18:37:53 -0800 Subject: [PATCH 08/12] Fix `DCN_NULLPOINTER_EXCEPTION` SpotBugs violations --- core/src/main/java/hudson/PluginManager.java | 4 ---- core/src/main/java/hudson/TcpSlaveAgentListener.java | 2 +- src/spotbugs/spotbugs-excludes.xml | 7 ------- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 7dad538d6f..0485275a16 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -272,10 +272,6 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } } LOGGER.log(WARNING, String.format("Provided custom plugin manager [%s] does not provide any of the suitable constructors. Using default.", pmClassName)); - } catch(NullPointerException e) { - // Class.forName and Class.getConstructor are supposed to never return null though a broken ClassLoader - // could break the contract. Just in case we introduce this specific catch to avoid polluting the logs with NPEs. - LOGGER.log(WARNING, String.format("Unable to instantiate custom plugin manager [%s]. Using default.", pmClassName)); } catch(ClassCastException e) { LOGGER.log(WARNING, String.format("Provided class [%s] does not extend PluginManager. Using default.", pmClassName)); } catch(Exception e) { diff --git a/core/src/main/java/hudson/TcpSlaveAgentListener.java b/core/src/main/java/hudson/TcpSlaveAgentListener.java index e7875e95bd..717c1df919 100644 --- a/core/src/main/java/hudson/TcpSlaveAgentListener.java +++ b/core/src/main/java/hudson/TcpSlaveAgentListener.java @@ -134,7 +134,7 @@ public final class TcpSlaveAgentListener extends Thread { } try { return new URL(Jenkins.get().getRootUrl()).getHost(); - } catch (MalformedURLException | NullPointerException e) { + } catch (MalformedURLException e) { throw new IllegalStateException("Could not get TcpSlaveAgentListener host name", e); } } diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index b6ebac958d..bd29bee8d5 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -91,13 +91,6 @@ - - - - - - - From 6c45a12cd79203fdd4ae2fcde7689f47262e9b07 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 18:48:04 -0800 Subject: [PATCH 09/12] Fix `RCN_REDUNDANT_NULLCHECK_OF_NONNULL_VALUE` SpotBugs violations --- core/src/main/java/hudson/model/Run.java | 1 + core/src/main/java/jenkins/model/Jenkins.java | 7 +------ core/src/main/java/jenkins/model/lazy/LazyBuildMixIn.java | 6 ++---- src/spotbugs/spotbugs-excludes.xml | 7 +------ 4 files changed, 5 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/hudson/model/Run.java b/core/src/main/java/hudson/model/Run.java index e0918ef219..e331a9e0c1 100644 --- a/core/src/main/java/hudson/model/Run.java +++ b/core/src/main/java/hudson/model/Run.java @@ -815,6 +815,7 @@ public abstract class Run ,RunT extends Run & Queue.Task & if (r == null) { // having two neighbors pointing to each other is important to make RunMap.removeValue work - JobT _parent = asRun().getParent(); - if (_parent == null) { - throw new IllegalStateException("no parent for " + asRun().number); - } + JobT _parent = Objects.requireNonNull(asRun().getParent(), "no parent for " + asRun().number); RunT pb = _parent.getLazyBuildMixIn()._getRuns().search(asRun().number - 1, AbstractLazyLoadRunMap.Direction.DESC); if (pb != null) { pb.getRunMixIn().nextBuildR = createReference(); // establish bi-di link diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index bd29bee8d5..f93a6bb253 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -489,12 +489,7 @@ - - - - - - + From f7bc2b5da658a58ba00d78ddb677f229ffe8f49e Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 19:08:42 -0800 Subject: [PATCH 10/12] Fix `OBL_UNSATISFIED_OBLIGATION` SpotBugs violations --- .../jenkins/security/s2m/AdminWhitelistRule.java | 16 ++++++++++------ .../jenkins/slaves/StandardOutputSwapper.java | 1 + src/spotbugs/spotbugs-excludes.xml | 7 ------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java b/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java index 09a236a04d..98bcac0f7b 100644 --- a/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java +++ b/core/src/main/java/jenkins/security/s2m/AdminWhitelistRule.java @@ -65,12 +65,16 @@ public class AdminWhitelistRule implements StaplerProxy { // overwrite 30-default.conf with what we think is the best from the core. // this file shouldn't be touched by anyone. For local customization, use other files in the conf dir. // 0-byte file is used as a signal from the admin to prevent this overwriting - placeDefaultRule( - new File(jenkins.getRootDir(), "secrets/whitelisted-callables.d/default.conf"), - getClass().getResourceAsStream("callable.conf")); - placeDefaultRule( - new File(jenkins.getRootDir(), "secrets/filepath-filters.d/30-default.conf"), - transformForWindows(getClass().getResourceAsStream("filepath-filter.conf"))); + try (InputStream callable = getClass().getResourceAsStream("callable.conf")) { + placeDefaultRule( + new File(jenkins.getRootDir(), "secrets/whitelisted-callables.d/default.conf"), + callable); + } + try (InputStream filepathFilter = getClass().getResourceAsStream("filepath-filter.conf")) { + placeDefaultRule( + new File(jenkins.getRootDir(), "secrets/filepath-filters.d/30-default.conf"), + transformForWindows(filepathFilter)); + } this.whitelisted = new CallableWhitelistConfig( new File(jenkins.getRootDir(),"secrets/whitelisted-callables.d/gui.conf")); diff --git a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java index 29b3df3fc3..d7e9381f04 100644 --- a/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java +++ b/core/src/main/java/jenkins/slaves/StandardOutputSwapper.java @@ -66,6 +66,7 @@ public class StandardOutputSwapper extends ComputerListener { } } + @SuppressFBWarnings(value = "OBL_UNSATISFIED_OBLIGATION", justification = "the obligation is satisfied with libc(7)") private void swap(StandardOutputStream stdout) throws IOException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, UnsatisfiedLinkError { // duplicate the OS file descriptor and create FileOutputStream around it int out = GNUCLibrary.LIBC.dup(1); diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index f93a6bb253..e042142993 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -385,13 +385,6 @@ - - - - - - - From cd91b39f569ff2fc17e77c740fdc0a7eeafd54bd Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Sat, 4 Dec 2021 21:36:09 -0800 Subject: [PATCH 11/12] Fix `SIC_INNER_SHOULD_BE_STATIC` SpotBugs violations --- core/src/main/java/hudson/FilePath.java | 4 ++-- core/src/main/java/hudson/PluginManager.java | 4 ++-- .../java/hudson/diagnosis/MemoryUsageMonitor.java | 2 +- core/src/main/java/hudson/model/Queue.java | 2 +- core/src/main/java/hudson/tasks/LogRotator.java | 2 +- .../hudson/triggers/SlowTriggerAdminMonitor.java | 2 +- src/spotbugs/spotbugs-excludes.xml | 13 ------------- 7 files changed, 8 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/hudson/FilePath.java b/core/src/main/java/hudson/FilePath.java index e4850c6361..1e0693c456 100644 --- a/core/src/main/java/hudson/FilePath.java +++ b/core/src/main/java/hudson/FilePath.java @@ -1035,7 +1035,7 @@ public final class FilePath implements SerializableOnlyOverRemoting { } // this reads from arbitrary URL - private final class Unpack extends MasterToSlaveFileCallable { + private static final class Unpack extends MasterToSlaveFileCallable { private final URL archive; Unpack(URL archive) { this.archive = archive; @@ -2938,7 +2938,7 @@ public final class FilePath implements SerializableOnlyOverRemoting { public @CheckForNull String validateAntFileMask(final String fileMasks, final int bound, final boolean caseSensitive) throws IOException, InterruptedException { return act(new ValidateAntFileMask(fileMasks, caseSensitive, bound)); } - private class ValidateAntFileMask extends MasterToSlaveFileCallable { + private static class ValidateAntFileMask extends MasterToSlaveFileCallable { private final String fileMasks; private final boolean caseSensitive; private final int bound; diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 0485275a16..4d2e1e63f3 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -1738,7 +1738,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas void cleanup(); } - class FileUploadPluginCopier implements PluginCopier { + static class FileUploadPluginCopier implements PluginCopier { private FileItem fileItem; FileUploadPluginCopier(FileItem fileItem) { @@ -1756,7 +1756,7 @@ public abstract class PluginManager extends AbstractModelObject implements OnMas } } - class UrlPluginCopier implements PluginCopier { + static class UrlPluginCopier implements PluginCopier { private String url; UrlPluginCopier(String url) { diff --git a/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java b/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java index f29bb4b4e2..06ed43cb1a 100644 --- a/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java +++ b/core/src/main/java/hudson/diagnosis/MemoryUsageMonitor.java @@ -51,7 +51,7 @@ public final class MemoryUsageMonitor extends PeriodicWork { /** * A memory group is conceptually a set of memory pools. */ - public final class MemoryGroup { + public static final class MemoryGroup { private final List pools = new ArrayList<>(); /** diff --git a/core/src/main/java/hudson/model/Queue.java b/core/src/main/java/hudson/model/Queue.java index 64af981be6..b03627d6b8 100644 --- a/core/src/main/java/hudson/model/Queue.java +++ b/core/src/main/java/hudson/model/Queue.java @@ -2453,7 +2453,7 @@ public class Queue extends ResourceController implements Saveable { @Restricted(NoExternalUse.class) @ExportedBean(defaultVisibility = 999) @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD", justification = "it is exported, so it might be used") - public class StubItem { + public static class StubItem { @Exported public StubTask task; diff --git a/core/src/main/java/hudson/tasks/LogRotator.java b/core/src/main/java/hudson/tasks/LogRotator.java index 6ac8037706..89ba0cf3a9 100644 --- a/core/src/main/java/hudson/tasks/LogRotator.java +++ b/core/src/main/java/hudson/tasks/LogRotator.java @@ -62,7 +62,7 @@ public class LogRotator extends BuildDiscarder { /** @deprecated Replaced by more generic {@link CompositeIOException}. */ @Deprecated - public class CollatedLogRotatorException extends IOException { + public static class CollatedLogRotatorException extends IOException { private static final long serialVersionUID = 5944233808072651101L; public final Collection collated; diff --git a/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java b/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java index bfba8a072b..67f7da9315 100644 --- a/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java +++ b/core/src/main/java/hudson/triggers/SlowTriggerAdminMonitor.java @@ -94,7 +94,7 @@ public class SlowTriggerAdminMonitor extends AdministrativeMonitor { return HttpResponses.redirectViaContextPath("/manage"); } - public class Value { + public static class Value { private final LocalDateTime time; private Class trigger; diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index e042142993..fbc7bb55fe 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -603,19 +603,6 @@ - - - - - - - - - - - - - From 426c6a1b54741ec692473b6a7ca9be6f497f02b4 Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 6 Dec 2021 14:03:50 -0800 Subject: [PATCH 12/12] Fix `RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT` SpotBugs violations --- core/src/main/java/hudson/model/queue/CauseOfBlockage.java | 3 ++- .../hudson/security/AuthenticationProcessingFilter2.java | 1 + src/spotbugs/spotbugs-excludes.xml | 6 +----- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/model/queue/CauseOfBlockage.java b/core/src/main/java/hudson/model/queue/CauseOfBlockage.java index dc0a59e9a0..9aad22d4dd 100644 --- a/core/src/main/java/hudson/model/queue/CauseOfBlockage.java +++ b/core/src/main/java/hudson/model/queue/CauseOfBlockage.java @@ -9,6 +9,7 @@ import hudson.model.Node; import hudson.model.Queue.Task; import hudson.model.TaskListener; import hudson.slaves.Cloud; +import java.util.Objects; import org.jvnet.localizer.Localizable; /** @@ -45,7 +46,7 @@ public abstract class CauseOfBlockage { * Obtains a simple implementation backed by {@link Localizable}. */ public static CauseOfBlockage fromMessage(@NonNull final Localizable l) { - l.getKey(); // null check + Objects.requireNonNull(l); return new CauseOfBlockage() { @Override public String getShortDescription() { diff --git a/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java b/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java index ecec5b9aea..6764550ab7 100644 --- a/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java +++ b/core/src/main/java/hudson/security/AuthenticationProcessingFilter2.java @@ -61,6 +61,7 @@ public final class AuthenticationProcessingFilter2 extends UsernamePasswordAuthe setPasswordParameter("j_password"); } + @SuppressFBWarnings(value = "RV_RETURN_VALUE_IGNORED_NO_SIDE_EFFECT", justification = "request.getSession(true) does in fact have a side effect") @Override protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, FilterChain chain, Authentication authResult) throws IOException, ServletException { if (SystemProperties.getInteger(SecurityRealm.class.getName() + ".sessionFixationProtectionMode", 1) == 2) { diff --git a/src/spotbugs/spotbugs-excludes.xml b/src/spotbugs/spotbugs-excludes.xml index fbc7bb55fe..5e5911a1f3 100644 --- a/src/spotbugs/spotbugs-excludes.xml +++ b/src/spotbugs/spotbugs-excludes.xml @@ -579,11 +579,7 @@ - - - - - +