From bd6d8b72da4ac52a8d048c5a36bd04d7e1717d19 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Tue, 10 Sep 2024 15:17:25 +0200 Subject: [PATCH] Enforce SpotBugs Add a few missing SpotBugs annotations Add serialVersionUID to LeastLoadBalancer$ExecutorChunkComparator since it is Serializable. Tested locally with: mvn clean -DskipTests verify --- pom.xml | 5 +++++ .../jenkinsci/plugins/leastload/LeastLoadBalancer.java | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index fb32c37..fa35577 100644 --- a/pom.xml +++ b/pom.xml @@ -38,6 +38,11 @@ HEAD + + Max + Low + + repo.jenkins-ci.org diff --git a/src/main/java/org/bstick12/jenkinsci/plugins/leastload/LeastLoadBalancer.java b/src/main/java/org/bstick12/jenkinsci/plugins/leastload/LeastLoadBalancer.java index 28c3cd3..c5aae3e 100644 --- a/src/main/java/org/bstick12/jenkinsci/plugins/leastload/LeastLoadBalancer.java +++ b/src/main/java/org/bstick12/jenkinsci/plugins/leastload/LeastLoadBalancer.java @@ -24,6 +24,8 @@ package org.bstick12.jenkinsci.plugins.leastload; import com.google.common.base.Preconditions; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.init.Initializer; import hudson.model.Computer; import hudson.model.Executor; @@ -58,7 +60,7 @@ */ public class LeastLoadBalancer extends LoadBalancer { - private static final Logger LOGGER = Logger.getLogger(LeastLoadBalancer.class.getCanonicalName()); + private static final Logger LOGGER = Logger.getLogger(LeastLoadBalancer.class.getName()); private static final Comparator EXECUTOR_CHUNK_COMPARATOR = Collections.reverseOrder(new ExecutorChunkComparator()); @@ -82,7 +84,8 @@ public static void register() { } @Override - public Mapping map(Task task, MappingWorksheet ws) { + @CheckForNull + public Mapping map(@NonNull Task task, MappingWorksheet ws) { try { @@ -180,6 +183,7 @@ public LoadBalancer getFallBackLoadBalancer() { } protected static class ExecutorChunkComparator implements Comparator, Serializable { + private static final long serialVersionUID = 1L; public int compare(ExecutorChunk ec1, ExecutorChunk ec2) { @@ -207,5 +211,4 @@ private boolean isIdle(Computer computer) { } } - }