Spotbugs fixes for LI_LAZY_INIT_STATIC, NP_LOAD_OF_KNOWN_NULL_VALUE, and UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD (#6099)

This commit is contained in:
Basil Crow authored and GitHub committed 2021-12-24 16:36:32 -08:00
1 parent 311804bedd
commit bd3823ce0d
6 files changed
+6 -18

No files matched your search

@@ -401,6 +401,7 @@ public class HudsonPrivateSecurityRealm extends AbstractPasswordBasedSecurityRea
* @return a {@link SignupInfo#SignupInfo(StaplerRequest) SignupInfo from given request}, with {@link
* SignupInfo#errors} containing errors (keyed by field name), if any of the supported fields are invalid
*/
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "written to by Stapler")
private SignupInfo validateAccountCreationForm(StaplerRequest req, boolean validateCaptcha) {
// form field validation
// this pattern needs to be generalized and moved to stapler
@@ -427,7 +427,7 @@ public abstract class ProcessTree implements Iterable<OSProcess>, IProcessTree,
}
/* package */ static Boolean vetoersExist;
/* package */ static volatile Boolean vetoersExist;
/**
* Gets the {@link ProcessTree} of the current system
@@ -30,7 +30,7 @@ public abstract class MasterToSlaveCallable<V, T extends Throwable> implements C
public Channel getChannelOrFail() throws ChannelClosedException {
final Channel ch = Channel.current();
if (ch == null) {
throw new ChannelClosedException(ch, new IllegalStateException("No channel associated with the thread"));
throw new ChannelClosedException((Channel) null, new IllegalStateException("No channel associated with the thread"));
}
return ch;
}
@@ -25,6 +25,7 @@ package jenkins.security.apitoken;
import edu.umd.cs.findbugs.annotations.NonNull;
import edu.umd.cs.findbugs.annotations.Nullable;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import hudson.Extension;
import hudson.model.AdministrativeMonitor;
import hudson.model.User;
@@ -160,6 +161,7 @@ public class LegacyApiTokenAdministrativeMonitor extends AdministrativeMonitor {
}
@RequirePOST
@SuppressFBWarnings(value = "UWF_UNWRITTEN_PUBLIC_OR_PROTECTED_FIELD", justification = "written to by Stapler")
public HttpResponse doRevokeAllSelected(@JsonBody RevokeAllSelectedModel content) throws IOException {
for (RevokeAllSelectedUserAndUuid value : content.values) {
if (value.userId == null) {
@@ -245,6 +245,7 @@ public class JSONSignatureValidator {
}
@SuppressFBWarnings(value = "NP_LOAD_OF_KNOWN_NULL_VALUE", justification = "https://github.com/spotbugs/spotbugs/issues/756")
protected Set<TrustAnchor> loadTrustAnchors(CertificateFactory cf) throws IOException {
// if we trust default root CAs, we end up trusting anyone who has a valid certificate,
// which isn't useful at all