diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/AllContainersRunningPodWatcher.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/AllContainersRunningPodWatcher.java index 81898026e4..9ff3e74077 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/AllContainersRunningPodWatcher.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/AllContainersRunningPodWatcher.java @@ -9,6 +9,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.TaskListener; import io.fabric8.kubernetes.api.model.ContainerStatus; import io.fabric8.kubernetes.api.model.Pod; @@ -19,9 +21,6 @@ import io.fabric8.kubernetes.client.WatcherException; import io.fabric8.kubernetes.client.utils.Serialization; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - /** * A pod watcher reporting when all containers are running */ @@ -35,7 +34,7 @@ public class AllContainersRunningPodWatcher implements Watcher { private KubernetesClient client; - @Nonnull + @NonNull private final TaskListener runListener; public AllContainersRunningPodWatcher(KubernetesClient client, Pod pod, @CheckForNull TaskListener runListener) { diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerEnvVar.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerEnvVar.java index 099a2997e7..f7c05919e3 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerEnvVar.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerEnvVar.java @@ -1,8 +1,7 @@ package org.csanchez.jenkins.plugins.kubernetes; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -42,7 +41,7 @@ public String getDisplayName() { @Extension public static class DescriptorVisibilityFilterImpl extends DescriptorVisibilityFilter { @Override - public boolean filter(@CheckForNull Object context, @Nonnull Descriptor descriptor) { + public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) { return !(descriptor instanceof ContainerEnvVar.DescriptorImpl); } } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/DefaultInProvisioning.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/DefaultInProvisioning.java index 8c127cae93..7411fcb5fa 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/DefaultInProvisioning.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/DefaultInProvisioning.java @@ -5,8 +5,7 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.annotation.CheckForNull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.Extension; import hudson.model.Computer; import hudson.model.Label; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/InProvisioning.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/InProvisioning.java index 7ec822b636..20ff0b1611 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/InProvisioning.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/InProvisioning.java @@ -4,9 +4,8 @@ import java.util.Set; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.model.Label; @@ -21,7 +20,7 @@ public abstract class InProvisioning implements ExtensionPoint { * @param label the {@link Label} being checked. * @return the agents names in provisioning according to all implementations of this extension point for the given label. */ - @Nonnull + @NonNull public static Set getAllInProvisioning(@CheckForNull Label label) { return all().stream() .flatMap(c -> c.getInProvisioning(label).stream()) @@ -38,6 +37,6 @@ public static ExtensionList all() { * @param label The label being checked * @return The agents names in provisioning for the current label. */ - @Nonnull + @NonNull public abstract Set getInProvisioning(Label label); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper.java index 792964e215..e241f41fe1 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapper.java @@ -5,6 +5,7 @@ import com.cloudbees.plugins.credentials.common.StandardCredentials; import com.cloudbees.plugins.credentials.common.StandardListBoxModel; import com.cloudbees.plugins.credentials.domains.URIRequirementBuilder; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.AbortException; import hudson.EnvVars; import hudson.Extension; @@ -29,7 +30,6 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.QueryParameter; -import javax.annotation.Nonnull; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.Writer; @@ -50,8 +50,8 @@ public class KubectlBuildWrapper extends SimpleBuildWrapper { private String caCertificate; @DataBoundConstructor - public KubectlBuildWrapper(@Nonnull String serverUrl, @Nonnull String credentialsId, - @Nonnull String caCertificate) { + public KubectlBuildWrapper(@NonNull String serverUrl, @NonNull String credentialsId, + @NonNull String caCertificate) { this.serverUrl = serverUrl; this.credentialsId = Util.fixEmpty(credentialsId); this.caCertificate = Util.fixEmptyAndTrim(caCertificate); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java index ae8ef89250..b767553837 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java @@ -20,13 +20,11 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import javax.servlet.ServletException; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.Main; import hudson.model.ItemGroup; -import hudson.model.Node; import hudson.util.XStream2; import jenkins.metrics.api.Metrics; import org.apache.commons.lang.StringUtils; @@ -61,8 +59,6 @@ import hudson.slaves.NodeProvisioner; import hudson.util.FormValidation; import hudson.util.ListBoxModel; -import io.fabric8.kubernetes.api.model.Pod; -import io.fabric8.kubernetes.api.model.PodList; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.KubernetesClientException; import io.fabric8.kubernetes.client.VersionInfo; @@ -101,7 +97,7 @@ public class KubernetesCloud extends Cloud { private String defaultsProviderTemplate; - @Nonnull + @NonNull private List templates = new ArrayList<>(); private String serverUrl; private boolean useJenkinsProxy; @@ -211,7 +207,7 @@ public void setDefaultsProviderTemplate(String defaultsProviderTemplate) { this.defaultsProviderTemplate = defaultsProviderTemplate; } - @Nonnull + @NonNull public List getTemplates() { return templates; } @@ -220,13 +216,13 @@ public List getTemplates() { * Returns all pod templates for this cloud including the dynamic ones. * @return all pod templates for this cloud including the dynamic ones. */ - @Nonnull + @NonNull public List getAllTemplates() { return PodTemplateSource.getAll(this); } @DataBoundSetter - public void setTemplates(@Nonnull List templates) { + public void setTemplates(@NonNull List templates) { this.templates = new ArrayList<>(templates); } @@ -235,7 +231,7 @@ public String getServerUrl() { } @DataBoundSetter - public void setServerUrl(@Nonnull String serverUrl) { + public void setServerUrl(@NonNull String serverUrl) { this.serverUrl = serverUrl; } @@ -295,7 +291,7 @@ public boolean isCapOnlyOnAlivePods() { * @return same as {@link #getJenkinsUrlOrNull}, if set * @throws IllegalStateException if no Jenkins URL could be computed. */ - @Nonnull + @NonNull public String getJenkinsUrlOrDie() { String url = getJenkinsUrlOrNull(); if (url == null) { @@ -580,7 +576,7 @@ public PodTemplate getTemplate(@CheckForNull Label label) { } @CheckForNull - public PodTemplate getTemplateById(@Nonnull String id) { + public PodTemplate getTemplateById(@NonNull String id) { return getAllTemplates().stream().filter(t -> id.equals(t.getId())).findFirst().orElse(null); } @@ -933,9 +929,9 @@ private Object readResolve() { @Extension public static class PodTemplateSourceImpl extends PodTemplateSource { - @Nonnull + @NonNull @Override - public List getList(@Nonnull KubernetesCloud cloud) { + public List getList(@NonNull KubernetesCloud cloud) { return cloud.getTemplates(); } } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFactoryAdapter.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFactoryAdapter.java index 175eb835a4..b0206a3a22 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFactoryAdapter.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFactoryAdapter.java @@ -5,11 +5,10 @@ import java.util.Collections; import java.util.logging.Logger; -import javax.annotation.CheckForNull; - import com.cloudbees.plugins.credentials.CredentialsMatchers; import com.cloudbees.plugins.credentials.CredentialsProvider; import com.cloudbees.plugins.credentials.common.StandardCredentials; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.ProxyConfiguration; import hudson.security.ACL; import hudson.util.Secret; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty.java index e286adf6eb..c0aa6e3ef8 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty.java @@ -10,8 +10,7 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.NonNull; import org.apache.commons.lang.StringUtils; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.DoNotUse; @@ -242,7 +241,7 @@ private static boolean isUsageRestrictedKubernetesCloud(Cloud cloud) { @Extension public static class DescriptorImpl extends AbstractFolderPropertyDescriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return Messages.KubernetesFolderProperty_displayName(); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java index cb825359b7..45420aa2f4 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java @@ -36,8 +36,7 @@ import java.util.logging.Logger; import java.util.stream.Collectors; -import javax.annotation.CheckForNull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.fabric8.kubernetes.client.KubernetesClientException; import jenkins.metrics.api.Metrics; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesProvisioningLimits.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesProvisioningLimits.java index d967e8f553..d05d1f8ce5 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesProvisioningLimits.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesProvisioningLimits.java @@ -5,8 +5,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.NonNull; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; @@ -68,7 +67,7 @@ public static KubernetesProvisioningLimits get() { * @param podTemplate the pod template used to schedule the agent * @param numExecutors the number of executors (pretty much always 1) */ - public synchronized boolean register(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate, int numExecutors) { + public synchronized boolean register(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate, int numExecutors) { int newGlobalCount = getGlobalCount(cloud.name) + numExecutors; if (newGlobalCount <= cloud.getContainerCap()) { int newPodTemplateCount = getPodTemplateCount(podTemplate.getId()) + numExecutors; @@ -96,7 +95,7 @@ public synchronized boolean register(@Nonnull KubernetesCloud cloud, @Nonnull Po * @param podTemplate the pod template used to schedule the agent * @param numExecutors the number of executors (pretty much always 1) */ - public synchronized void unregister(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate, int numExecutors) { + public synchronized void unregister(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate, int numExecutors) { int newGlobalCount = getGlobalCount(cloud.name) - numExecutors; if (newGlobalCount < 0) { LOGGER.log(Level.WARNING, "Global count for " + cloud.name + " went below zero. There is likely a bug in kubernetes-plugin"); @@ -112,13 +111,13 @@ public synchronized void unregister(@Nonnull KubernetesCloud cloud, @Nonnull Pod LOGGER.log(Level.FINEST, () -> podTemplate.getName() + " template limit: " + Math.max(0, newPodTemplateCount) + "/" + podTemplate.getInstanceCap()); } - @Nonnull + @NonNull @Restricted(NoExternalUse.class) int getGlobalCount(String cloudName) { return cloudCounts.getOrDefault(cloudName, 0); } - @Nonnull + @NonNull @Restricted(NoExternalUse.class) int getPodTemplateCount(String podTemplate) { return podTemplateCounts.getOrDefault(podTemplate, 0); @@ -127,7 +126,7 @@ int getPodTemplateCount(String podTemplate) { @Extension public static class NodeListenerImpl extends NodeListener { @Override - protected void onDeleted(@Nonnull Node node) { + protected void onDeleted(@NonNull Node node) { if (node instanceof KubernetesSlave) { KubernetesSlave kubernetesNode = (KubernetesSlave) node; PodTemplate template = kubernetesNode.getTemplateOrNull(); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java index 760de0e0ab..7debfe3422 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java @@ -12,9 +12,8 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.FilePath; import hudson.Util; import hudson.slaves.SlaveComputer; @@ -46,7 +45,6 @@ import hudson.slaves.Cloud; import hudson.slaves.CloudRetentionStrategy; import hudson.slaves.ComputerLauncher; -import hudson.slaves.OfflineCause; import hudson.slaves.RetentionStrategy; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.client.KubernetesClient; @@ -76,7 +74,7 @@ public class KubernetesSlave extends AbstractCloudSlave { private final String cloudName; private String namespace; - @Nonnull + @NonNull private String podTemplateId; private transient PodTemplate template; private transient Set executables = new HashSet<>(); @@ -84,7 +82,7 @@ public class KubernetesSlave extends AbstractCloudSlave { @CheckForNull private transient Pod pod; - @Nonnull + @NonNull public PodTemplate getTemplate() { // Look up updated pod template after a restart PodTemplate template = getTemplateOrNull(); @@ -94,7 +92,7 @@ public PodTemplate getTemplate() { return template; } - @Nonnull + @NonNull public String getTemplateId() { return podTemplateId; } @@ -147,7 +145,7 @@ public KubernetesSlave(PodTemplate template, String nodeDescription, String clou this(getSlaveName(template), template, nodeDescription, cloudName, labelStr, new KubernetesLauncher(), rs); } - protected KubernetesSlave(String name, @Nonnull PodTemplate template, String nodeDescription, String cloudName, String labelStr, + protected KubernetesSlave(String name, @NonNull PodTemplate template, String nodeDescription, String cloudName, String labelStr, ComputerLauncher computerLauncher, RetentionStrategy rs) throws Descriptor.FormException, IOException { super(name, null, computerLauncher); @@ -166,11 +164,11 @@ public String getCloudName() { return cloudName; } - public void setNamespace(@Nonnull String namespace) { + public void setNamespace(@NonNull String namespace) { this.namespace = namespace; } - @Nonnull + @NonNull public String getNamespace() { return namespace; } @@ -225,7 +223,7 @@ public Optional getPod() { * @return the cloud instance which created this agent. * @throws IllegalStateException if the cloud doesn't exist anymore, or is not a {@link KubernetesCloud}. */ - @Nonnull + @NonNull public KubernetesCloud getKubernetesCloud() { return getKubernetesCloud(getCloudName()); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodEnvVar.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodEnvVar.java index 532caeae6c..8d886ffecb 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodEnvVar.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodEnvVar.java @@ -1,8 +1,7 @@ package org.csanchez.jenkins.plugins.kubernetes; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -33,6 +32,7 @@ public String toString() { @Symbol("podEnvVar") public static class DescriptorImpl extends KeyValueEnvVar.DescriptorImpl { @Override + @NonNull public String getDisplayName() { return "[Deprecated: use Environment Variable] Global Environment Variable (applied to all containers)"; } @@ -41,7 +41,7 @@ public String getDisplayName() { @Extension public static class DescriptorVisibilityFilterImpl extends DescriptorVisibilityFilter { @Override - public boolean filter(@CheckForNull Object context, @Nonnull Descriptor descriptor) { + public boolean filter(@CheckForNull Object context, @NonNull Descriptor descriptor) { return !(descriptor instanceof PodEnvVar.DescriptorImpl); } } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodLabel.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodLabel.java index 525a7cad28..50a37a0cc2 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodLabel.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodLabel.java @@ -1,5 +1,6 @@ package org.csanchez.jenkins.plugins.kubernetes; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.AbstractDescribableImpl; import hudson.model.Descriptor; @@ -7,7 +8,6 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -52,8 +52,8 @@ public void setValue(String value) { * @param labels collection of pod labels to convert to a map * @return immutable map of pod labels */ - @Nonnull - static Map toMap(@Nonnull Iterable labels) { + @NonNull + static Map toMap(@NonNull Iterable labels) { Map builder = new HashMap<>(); for (PodLabel podLabel : labels) { builder.put(podLabel.getKey(), substituteEnv(podLabel.getValue())); @@ -66,8 +66,8 @@ static Map toMap(@Nonnull Iterable labels) { * @param labels labels map * @return list of pod labels */ - @Nonnull - static List fromMap(@Nonnull Map labels) { + @NonNull + static List fromMap(@NonNull Map labels) { List list = new ArrayList<>(); for (Map.Entry label : labels.entrySet()) { list.add(new PodLabel(label.getKey(), label.getValue())); @@ -109,7 +109,7 @@ public String toString() { @Symbol("podLabel") public static class DescriptorImpl extends Descriptor { @Override - @Nonnull + @NonNull public String getDisplayName() { return "Pod Label"; } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java index 780bd682e9..3005f5e82a 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java @@ -6,7 +6,6 @@ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -17,9 +16,8 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.AbstractDescribableImpl; import hudson.model.Descriptor; import hudson.model.DescriptorVisibilityFilter; @@ -179,7 +177,7 @@ public class PodTemplate extends AbstractDescribableImpl implements */ private transient List yamls; - @Nonnull + @NonNull public String getId() { return id; } @@ -671,7 +669,7 @@ public void setNodeProperties(List> properties) { this.getNodeProperties().addAll(properties); } - @Nonnull + @NonNull public PodTemplateToolLocation getNodeProperties(){ if( this.nodeProperties == null) this.nodeProperties = new PodTemplateToolLocation(this); @@ -724,14 +722,14 @@ public void setResourceRequestCpu(String resourceRequestCpu) { } @DataBoundSetter - public void setVolumes(@Nonnull List items) { + public void setVolumes(@NonNull List items) { synchronized (this.volumes) { this.volumes.clear(); this.volumes.addAll(items); } } - @Nonnull + @NonNull public List getVolumes() { if (volumes == null) { return Collections.emptyList(); @@ -739,7 +737,7 @@ public List getVolumes() { return volumes; } - @Nonnull + @NonNull public WorkspaceVolume getWorkspaceVolume() { return workspaceVolume == null ? WorkspaceVolume.getDefault() : workspaceVolume; } @@ -750,14 +748,14 @@ public void setWorkspaceVolume(WorkspaceVolume workspaceVolume) { } @DataBoundSetter - public void setContainers(@Nonnull List items) { + public void setContainers(@NonNull List items) { synchronized (this.containers) { this.containers.clear(); this.containers.addAll(items); } } - @Nonnull + @NonNull public List getContainers() { if (containers == null) { return Collections.emptyList(); @@ -777,7 +775,7 @@ public void setYaml(String yaml) { this.yaml = Util.fixEmpty(yaml); } - @Nonnull + @NonNull public List getYamls() { if (yamls == null || yamls.isEmpty()) { if (yaml != null) { @@ -818,7 +816,7 @@ public void setPodRetention(PodRetention podRetention) { this.podRetention = PodRetention.getPodTemplateDefault().equals(podRetention) ? null : podRetention; } - @Nonnull + @NonNull public TaskListener getListener() { return listener == null ? TaskListener.NULL : listener; } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java index 18be674bbb..94c2f80b25 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateBuilder.java @@ -39,6 +39,8 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.Util; import io.fabric8.kubernetes.api.model.PodSpecFluent; @@ -75,9 +77,6 @@ import io.jenkins.lib.versionnumber.JavaSpecificationVersion; import jenkins.model.Jenkins; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - import static org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud.JNLP_NAME; import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.combine; import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.isNullOrEmpty; @@ -147,7 +146,7 @@ private static String getDefaultImageName() { return name; } - public PodTemplateBuilder withSlave(@Nonnull KubernetesSlave slave) { + public PodTemplateBuilder withSlave(@NonNull KubernetesSlave slave) { this.agent = slave; this.cloud = slave.getKubernetesCloud(); return this; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilter.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilter.java index 59cbd41d2c..809a251da4 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilter.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilter.java @@ -3,9 +3,8 @@ import java.util.ArrayList; import java.util.List; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionList; import hudson.ExtensionPoint; import hudson.model.Label; @@ -30,7 +29,7 @@ public static ExtensionList all() { * @param label The label that was requested for provisioning * @return The pod template list after filtering */ - public static List applyAll(@Nonnull KubernetesCloud cloud, @Nonnull List podTemplates, @CheckForNull Label label) { + public static List applyAll(@NonNull KubernetesCloud cloud, @NonNull List podTemplates, @CheckForNull Label label) { List result = new ArrayList<>(); for (PodTemplate t : podTemplates) { PodTemplate output = t; @@ -56,5 +55,5 @@ public static List applyAll(@Nonnull KubernetesCloud cloud, @Nonnul * @return A new pod template after transformation. It can be null if the filter denies access to the given pod template. */ @CheckForNull - protected abstract PodTemplate transform(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate, @CheckForNull Label label); + protected abstract PodTemplate transform(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate, @CheckForNull Label label); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateLabelFilter.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateLabelFilter.java index 309a73e762..4733ba1bf1 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateLabelFilter.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateLabelFilter.java @@ -1,8 +1,7 @@ package org.csanchez.jenkins.plugins.kubernetes; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.Label; import hudson.model.Node; @@ -13,7 +12,7 @@ @Extension(ordinal = 1000) public class PodTemplateLabelFilter extends PodTemplateFilter { @Override - protected PodTemplate transform(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate, @CheckForNull Label label) { + protected PodTemplate transform(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate, @CheckForNull Label label) { if ((label == null && podTemplate.getNodeUsageMode() == Node.Mode.NORMAL) || (label != null && label.matches(podTemplate.getLabelSet()))) { return podTemplate; } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateSource.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateSource.java index c91fc500d2..682776e1ee 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateSource.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateSource.java @@ -5,8 +5,7 @@ import java.util.Collection; import java.util.List; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionList; import hudson.ExtensionPoint; @@ -14,7 +13,7 @@ * A source of pod templates. */ public abstract class PodTemplateSource implements ExtensionPoint { - public static List getAll(@Nonnull KubernetesCloud cloud) { + public static List getAll(@NonNull KubernetesCloud cloud) { return ExtensionList.lookup(PodTemplateSource.class) .stream() .map(s -> s.getList(cloud)) @@ -27,6 +26,6 @@ public static List getAll(@Nonnull KubernetesCloud cloud) { * @return The list of {@link PodTemplate} contributed by this implementation. * @param cloud */ - @Nonnull - protected abstract List getList(@Nonnull KubernetesCloud cloud); + @NonNull + protected abstract List getList(@NonNull KubernetesCloud cloud); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java index 2cb2575533..fce974a0b8 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateUtils.java @@ -24,10 +24,9 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.Nullable; import hudson.slaves.NodeProperty; import org.apache.commons.lang.StringUtils; import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar; @@ -81,7 +80,7 @@ public class PodTemplateUtils { * @param template The actual container template * @return The combined container template. */ - public static ContainerTemplate combine(@CheckForNull ContainerTemplate parent, @Nonnull ContainerTemplate template) { + public static ContainerTemplate combine(@CheckForNull ContainerTemplate parent, @NonNull ContainerTemplate template) { if (template == null) { throw new IllegalArgumentException("Container template should not be null"); } @@ -144,7 +143,7 @@ public static ContainerTemplate combine(@CheckForNull ContainerTemplate parent, * The actual container * @return The combined container. */ - public static Container combine(@CheckForNull Container parent, @Nonnull Container template) { + public static Container combine(@CheckForNull Container parent, @NonNull Container template) { if (template == null) { throw new IllegalArgumentException("Container template should not be null"); } @@ -344,7 +343,7 @@ public static Pod combine(Pod parent, Pod template) { return pod; } - @Nonnull + @NonNull private static List combineContainers(List parent, List child) { LinkedHashMap combinedContainers = new LinkedHashMap<>(); // Need to retain insertion order Map parentContainers = parent.stream() @@ -356,7 +355,7 @@ private static List combineContainers(List parent, List(combinedContainers.values()); } - private static List combineVolumes(@Nonnull List volumes1, @Nonnull List volumes2) { + private static List combineVolumes(@NonNull List volumes1, @NonNull List volumes2) { Map volumesByName = volumes1.stream().collect(Collectors.toMap(Volume::getName, Function.identity())); volumes2.forEach(v -> volumesByName.put(v.getName(), v)); return new ArrayList<>(volumesByName.values()); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStepExecution.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStepExecution.java index 06d1f58cce..1d33cb7a74 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStepExecution.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerStepExecution.java @@ -8,8 +8,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.plugins.workflow.steps.BodyExecutionCallback; import org.jenkinsci.plugins.workflow.steps.BodyInvoker; import org.jenkinsci.plugins.workflow.steps.EnvironmentExpander; @@ -93,7 +92,7 @@ public boolean start() throws Exception { } @Override - public void stop(@Nonnull Throwable cause) throws Exception { + public void stop(@NonNull Throwable cause) throws Exception { LOGGER.log(Level.FINE, "Stopping container step."); closeQuietly(getContext(), decorator); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java index c9ab7704dd..d3a397b359 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesDeclarativeAgent.java @@ -4,12 +4,10 @@ import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionList; import hudson.Util; -import hudson.model.Descriptor; import hudson.model.Label; import hudson.util.ListBoxModel; import org.apache.commons.lang.StringUtils; import org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate; -import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; import org.csanchez.jenkins.plugins.kubernetes.PodTemplate; import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention; import org.csanchez.jenkins.plugins.kubernetes.pod.yaml.YamlMergeStrategy; @@ -24,7 +22,6 @@ import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.QueryParameter; -import javax.annotation.Nonnull; import java.util.Collections; import java.util.List; import java.util.Map; @@ -402,7 +399,7 @@ public DescriptorImpl() { } } - @Nonnull + @NonNull @Override public String getDisplayName() { return Messages.KubernetesDeclarativeAgent_displayName(); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateMap.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateMap.java index b7feb3c0ee..759a607bfa 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateMap.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateMap.java @@ -6,8 +6,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.logging.Logger; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.NonNull; import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; import org.csanchez.jenkins.plugins.kubernetes.PodTemplate; import org.csanchez.jenkins.plugins.kubernetes.PodTemplateSource; @@ -37,12 +36,12 @@ public static PodTemplateMap get() { * @param cloud The kubernetes cloud instance for which templates are needed * @return a read-only view of the templates available for the corresponding cloud instance. */ - @Nonnull - public List getTemplates(@Nonnull KubernetesCloud cloud) { + @NonNull + public List getTemplates(@NonNull KubernetesCloud cloud) { return Collections.unmodifiableList(getOrCreateTemplateList(cloud)); } - private List getOrCreateTemplateList(@Nonnull KubernetesCloud cloud) { + private List getOrCreateTemplateList(@NonNull KubernetesCloud cloud) { List podTemplates = map.get(cloud.name); return podTemplates == null ? new CopyOnWriteArrayList<>() : podTemplates; } @@ -52,7 +51,7 @@ private List getOrCreateTemplateList(@Nonnull KubernetesCloud cloud * @param cloud The cloud instance. * @param podTemplate The pod template to add. */ - public void addTemplate(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate) { + public void addTemplate(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate) { synchronized (this.map) { List list = getOrCreateTemplateList(cloud); list.add(podTemplate); @@ -60,7 +59,7 @@ public void addTemplate(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate pod } } - public void removeTemplate(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate) { + public void removeTemplate(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate) { synchronized (this.map) { getOrCreateTemplateList(cloud).remove(podTemplate); } @@ -69,9 +68,9 @@ public void removeTemplate(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate @Extension public static class PodTemplateSourceImpl extends PodTemplateSource { - @Nonnull + @NonNull @Override - public List getList(@Nonnull KubernetesCloud cloud) { + public List getList(@NonNull KubernetesCloud cloud) { return PodTemplateMap.get().getTemplates(cloud); } } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java index 86364212f9..c7e67507c9 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStep.java @@ -9,6 +9,7 @@ import java.util.Set; import java.util.stream.Collectors; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.slaves.Cloud; import hudson.util.ListBoxModel; import jenkins.model.Jenkins; @@ -36,8 +37,6 @@ import hudson.model.TaskListener; import org.kohsuke.stapler.QueryParameter; -import javax.annotation.CheckForNull; - public class PodTemplateStep extends Step implements Serializable { private static final long serialVersionUID = 5588861066775717487L; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/SecretsMasker.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/SecretsMasker.java index 95b36f828d..0e8d976350 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/SecretsMasker.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/SecretsMasker.java @@ -16,6 +16,7 @@ package org.csanchez.jenkins.plugins.kubernetes.pipeline; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.Extension; import hudson.remoting.Channel; import hudson.util.LogTaskListener; @@ -40,7 +41,6 @@ import java.util.concurrent.TimeUnit; import java.util.logging.Level; import java.util.logging.Logger; -import javax.annotation.CheckForNull; import okhttp3.Response; import org.csanchez.jenkins.plugins.kubernetes.KubernetesComputer; import org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultNodeSelector.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultNodeSelector.java index c6799ea45b..966f379ee3 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultNodeSelector.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultNodeSelector.java @@ -1,10 +1,10 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import io.fabric8.kubernetes.api.model.Pod; import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; -import javax.annotation.Nonnull; import java.util.Collections; /** @@ -12,9 +12,9 @@ */ @Extension public class DefaultNodeSelector implements PodDecorator { - @Nonnull + @NonNull @Override - public Pod decorate(@Nonnull KubernetesCloud kubernetesCloud, @Nonnull Pod pod) { + public Pod decorate(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod) { // default OS: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ if (pod.getSpec().getRuntimeClassName() == null && (pod.getSpec().getNodeSelector() == null || pod.getSpec().getNodeSelector().isEmpty()) && diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultRestartPolicy.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultRestartPolicy.java index fc0e47e566..4957425444 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultRestartPolicy.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultRestartPolicy.java @@ -1,20 +1,19 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import io.fabric8.kubernetes.api.model.Pod; import org.apache.commons.lang.StringUtils; import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; -import javax.annotation.Nonnull; - /** * Sets the restart policy to Never. */ @Extension public class DefaultRestartPolicy implements PodDecorator { - @Nonnull + @NonNull @Override - public Pod decorate(@Nonnull KubernetesCloud kubernetesCloud, @Nonnull Pod pod) { + public Pod decorate(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod) { if (StringUtils.isBlank(pod.getSpec().getRestartPolicy())) { pod.getSpec().setRestartPolicy("Never"); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultWorkspaceVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultWorkspaceVolume.java index f90723cfce..a8a2b401da 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultWorkspaceVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/DefaultWorkspaceVolume.java @@ -1,5 +1,6 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import io.fabric8.kubernetes.api.model.Container; import io.fabric8.kubernetes.api.model.Pod; @@ -12,7 +13,6 @@ import org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate; import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; @@ -35,9 +35,9 @@ public class DefaultWorkspaceVolume implements PodDecorator { .withReadOnly(false) .build(); - @Nonnull + @NonNull @Override - public Pod decorate(@Nonnull KubernetesCloud kubernetesCloud, @Nonnull Pod pod) { PodSpec podSpec = pod.getSpec(); + public Pod decorate(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod) { PodSpec podSpec = pod.getSpec(); // default workspace volume, add an empty volume to share the workspace across the pod if (podSpec.getVolumes().stream().noneMatch(WORKSPACE_VOLUME_PREDICATE)) { // @formatter:off diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecorator.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecorator.java index fee23c10c0..ff9ca8ea7a 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecorator.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecorator.java @@ -1,25 +1,24 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionList; import hudson.ExtensionPoint; import io.fabric8.kubernetes.api.model.Pod; import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; -import javax.annotation.Nonnull; - /** * Allows to alter a pod definition after it has been built from the yaml and DSL/GUI configuration. */ public interface PodDecorator extends ExtensionPoint { - @Nonnull - static Pod decorateAll(@Nonnull KubernetesCloud kubernetesCloud, @Nonnull Pod pod) { + @NonNull + static Pod decorateAll(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod) { for (PodDecorator decorator : ExtensionList.lookup(PodDecorator.class)) { pod = decorator.decorate(kubernetesCloud, pod); } return pod; } - @Nonnull - Pod decorate(@Nonnull KubernetesCloud kubernetesCloud, @Nonnull Pod pod); + @NonNull + Pod decorate(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Merge.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Merge.java index 3110049af9..16b379dace 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Merge.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Merge.java @@ -1,5 +1,6 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.yaml; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.Descriptor; import io.fabric8.kubernetes.api.model.Pod; @@ -7,7 +8,6 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; import java.util.List; import java.util.stream.Collectors; @@ -33,7 +33,7 @@ public String toString() { @Extension @Symbol("merge") public static class DescriptorImpl extends Descriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return "Merge"; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Overrides.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Overrides.java index 2bc9e5e8ed..67926f0a2e 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Overrides.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/Overrides.java @@ -1,12 +1,12 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.yaml; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.Extension; import hudson.model.Descriptor; import io.fabric8.kubernetes.api.model.Pod; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; -import javax.annotation.Nonnull; import java.util.List; import static org.csanchez.jenkins.plugins.kubernetes.PodTemplateUtils.parseFromYaml; @@ -35,7 +35,7 @@ public String toString() { @Extension @Symbol("override") public static class DescriptorImpl extends Descriptor { - @Nonnull + @NonNull @Override public String getDisplayName() { return "Override"; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/YamlMergeStrategy.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/YamlMergeStrategy.java index e1ca6b61cd..83479b2809 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/YamlMergeStrategy.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/yaml/YamlMergeStrategy.java @@ -1,10 +1,10 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.yaml; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionPoint; import hudson.model.AbstractDescribableImpl; import io.fabric8.kubernetes.api.model.Pod; -import javax.annotation.Nonnull; import java.io.Serializable; import java.util.List; @@ -13,7 +13,7 @@ public static YamlMergeStrategy defaultStrategy() { return new Overrides(); } - public abstract Pod merge(@Nonnull List yamls); + public abstract Pod merge(@NonNull List yamls); @Override public String toString() { diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/EmptyDirVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/EmptyDirVolume.java index 4f1297c4a7..86e8e0f2f3 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/EmptyDirVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/EmptyDirVolume.java @@ -24,9 +24,8 @@ package org.csanchez.jenkins.plugins.kubernetes.volumes; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -59,7 +58,7 @@ public String getMedium() { return getMemory() ? MEMORY_MEDIUM : DEFAULT_MEDIUM; } - @Nonnull + @NonNull public Boolean getMemory() { return memory != null && memory; } @@ -78,8 +77,9 @@ public String toString() { @Symbol("emptyDirVolume") public static class DescriptorImpl extends Descriptor { @Override + @NonNull public String getDisplayName() { return "Empty Dir Volume"; } } -} \ No newline at end of file +} diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/NfsVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/NfsVolume.java index 6106b350fb..2d6b2488bb 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/NfsVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/NfsVolume.java @@ -24,9 +24,8 @@ package org.csanchez.jenkins.plugins.kubernetes.volumes; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -69,7 +68,7 @@ public String getServerPath() { return serverPath; } - @Nonnull + @NonNull public Boolean getReadOnly() { return readOnly != null && readOnly; } @@ -78,8 +77,9 @@ public Boolean getReadOnly() { @Symbol("nfsVolume") public static class DescriptorImpl extends Descriptor { @Override + @NonNull public String getDisplayName() { return "NFS Volume"; } } -} \ No newline at end of file +} diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim.java index a0f029117b..7c8378e3b2 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/PersistentVolumeClaim.java @@ -24,9 +24,8 @@ package org.csanchez.jenkins.plugins.kubernetes.volumes; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -57,7 +56,7 @@ public String getClaimName() { return claimName; } - @Nonnull + @NonNull public Boolean getReadOnly() { return readOnly != null && readOnly; } @@ -81,4 +80,4 @@ public String getDisplayName() { return "Persistent Volume Claim"; } } -} \ No newline at end of file +} diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/DynamicPVCWorkspaceVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/DynamicPVCWorkspaceVolume.java index e7ea282f4c..49120847de 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/DynamicPVCWorkspaceVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/DynamicPVCWorkspaceVolume.java @@ -1,5 +1,6 @@ package org.csanchez.jenkins.plugins.kubernetes.volumes.workspace; +import edu.umd.cs.findbugs.annotations.CheckForNull; import hudson.Extension; import hudson.Util; import hudson.model.Descriptor; @@ -20,7 +21,6 @@ import org.kohsuke.stapler.DataBoundSetter; import org.kohsuke.stapler.interceptor.RequirePOST; -import javax.annotation.CheckForNull; import java.util.Collections; import java.util.Map; import java.util.Objects; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume.java index c7620cb6c0..a7bb544002 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/EmptyDirWorkspaceVolume.java @@ -24,9 +24,8 @@ package org.csanchez.jenkins.plugins.kubernetes.volumes.workspace; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -54,7 +53,7 @@ public String getMedium() { return getMemory() ? MEMORY_MEDIUM : DEFAULT_MEDIUM; } - @Nonnull + @NonNull public Boolean getMemory() { return memory != null && memory; } @@ -86,8 +85,9 @@ public int hashCode() { @Symbol("emptyDirWorkspaceVolume") public static class DescriptorImpl extends Descriptor { @Override + @NonNull public String getDisplayName() { return "Empty Dir Workspace Volume"; } } -} \ No newline at end of file +} diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/NfsWorkspaceVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/NfsWorkspaceVolume.java index 5092e7951a..a1a0c09c2e 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/NfsWorkspaceVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/NfsWorkspaceVolume.java @@ -24,9 +24,8 @@ package org.csanchez.jenkins.plugins.kubernetes.volumes.workspace; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -65,7 +64,7 @@ public String getServerPath() { return serverPath; } - @Nonnull + @NonNull public Boolean getReadOnly() { return readOnly != null && readOnly; } @@ -89,8 +88,9 @@ public int hashCode() { @Symbol("nfsWorkspaceVolume") public static class DescriptorImpl extends Descriptor { @Override + @NonNull public String getDisplayName() { return "NFS Workspace Volume"; } } -} \ No newline at end of file +} diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/PersistentVolumeClaimWorkspaceVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/PersistentVolumeClaimWorkspaceVolume.java index 44117150fd..ce478f5012 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/PersistentVolumeClaimWorkspaceVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/PersistentVolumeClaimWorkspaceVolume.java @@ -24,9 +24,8 @@ package org.csanchez.jenkins.plugins.kubernetes.volumes.workspace; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; - +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -52,7 +51,7 @@ public String getClaimName() { return claimName; } - @Nonnull + @NonNull public Boolean getReadOnly() { return readOnly != null && readOnly; } @@ -90,4 +89,4 @@ public String getDisplayName() { return "Persistent Volume Claim Workspace Volume"; } } -} \ No newline at end of file +} diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapperTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapperTest.java index b2911d83c6..cda096687d 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapperTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/KubectlBuildWrapperTest.java @@ -5,8 +5,6 @@ import com.cloudbees.plugins.credentials.impl.UsernamePasswordCredentialsImpl; import hudson.model.Result; import org.csanchez.jenkins.plugins.kubernetes.pipeline.AbstractKubernetesPipelineTest; -import org.jenkinsci.plugins.workflow.flow.FlowDurabilityHint; -import org.jenkinsci.plugins.workflow.flow.GlobalDefaultFlowDurabilityLevel; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/MetricNamesTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/MetricNamesTest.java index 73ee0cbc39..892125a133 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/MetricNamesTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/MetricNamesTest.java @@ -1,7 +1,5 @@ package org.csanchez.jenkins.plugins.kubernetes; -import antlr.ANTLRException; -import hudson.model.Label; import hudson.model.labels.LabelAtom; import org.junit.Assert; import org.junit.Test; @@ -47,4 +45,4 @@ public void metricNameForLabelAddsLabelValue() { Assert.assertEquals(expected, actual); } -} \ No newline at end of file +} diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilterTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilterTest.java index 520e738bd6..7a548de9ed 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilterTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateFilterTest.java @@ -1,5 +1,7 @@ package org.csanchez.jenkins.plugins.kubernetes; +import edu.umd.cs.findbugs.annotations.CheckForNull; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.model.Label; import org.hamcrest.Matchers; import org.junit.Rule; @@ -7,8 +9,6 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.TestExtension; -import javax.annotation.CheckForNull; -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; @@ -23,7 +23,7 @@ public class PodTemplateFilterTest { public static class PodTemplateFilter1 extends PodTemplateFilter { @CheckForNull @Override - protected PodTemplate transform(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate, @CheckForNull Label label) { + protected PodTemplate transform(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate, @CheckForNull Label label) { return addYaml(podTemplate, "yaml1"); } } @@ -32,7 +32,7 @@ protected PodTemplate transform(@Nonnull KubernetesCloud cloud, @Nonnull PodTemp public static class PodTemplateFilter2 extends PodTemplateFilter { @CheckForNull @Override - protected PodTemplate transform(@Nonnull KubernetesCloud cloud, @Nonnull PodTemplate podTemplate, @CheckForNull Label label) { + protected PodTemplate transform(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate, @CheckForNull Label label) { return addYaml(podTemplate, "yaml2"); } } @@ -48,7 +48,7 @@ public void multipleFilters() { assertThat(result.get(0).getYamls(), Matchers.containsInAnyOrder("yaml1", "yaml2")); } - private static PodTemplate addYaml(@Nonnull PodTemplate podTemplate, String yaml) { + private static PodTemplate addYaml(@NonNull PodTemplate podTemplate, String yaml) { PodTemplate result = new PodTemplate(podTemplate); List yamls = new ArrayList<>(result.getYamls()); yamls.add(yaml); diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateJenkinsTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateJenkinsTest.java index 67ccb8a183..66b14de600 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateJenkinsTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateJenkinsTest.java @@ -8,7 +8,6 @@ import java.math.BigInteger; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.Map; import java.util.stream.Collectors; diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/AbstractKubernetesPipelineTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/AbstractKubernetesPipelineTest.java index e10286752b..e92b001251 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/AbstractKubernetesPipelineTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/AbstractKubernetesPipelineTest.java @@ -41,7 +41,6 @@ import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; import org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil; import org.csanchez.jenkins.plugins.kubernetes.PodTemplate; -import org.csanchez.jenkins.plugins.kubernetes.PodTemplateBuilder; import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar; import org.csanchez.jenkins.plugins.kubernetes.model.SecretEnvVar; import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar; diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java index 16e5756cfe..28c9238d89 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecoratorTest.java @@ -28,7 +28,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.arrayContaining; import static org.hamcrest.Matchers.containsString; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -62,8 +61,6 @@ import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; import org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave; import org.csanchez.jenkins.plugins.kubernetes.PodTemplate; -import org.hamcrest.MatcherAssert; -import org.hamcrest.Matchers; import org.jenkinsci.plugins.workflow.steps.StepContext; import org.junit.After; import org.junit.Before; @@ -81,7 +78,6 @@ import hudson.Launcher.ProcStarter; import hudson.model.Node; import hudson.util.StreamTaskListener; -import io.fabric8.kubernetes.api.model.Container; import io.fabric8.kubernetes.api.model.ContainerBuilder; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineOverridenNamespaceTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineOverridenNamespaceTest.java index 5ad12ed5da..0e9bc1ee13 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineOverridenNamespaceTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesPipelineOverridenNamespaceTest.java @@ -3,8 +3,6 @@ import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.testingNamespace; import static org.junit.Assert.assertNotNull; -import io.fabric8.kubernetes.api.model.NamespaceBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; import org.junit.Test; import java.util.HashMap; diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NoDelayProvisionerStrategyTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NoDelayProvisionerStrategyTest.java index d2793c5eb6..307093f301 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NoDelayProvisionerStrategyTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NoDelayProvisionerStrategyTest.java @@ -1,5 +1,6 @@ package org.csanchez.jenkins.plugins.kubernetes.pipeline; +import edu.umd.cs.findbugs.annotations.NonNull; import hudson.ExtensionList; import hudson.model.Label; import hudson.model.Node; @@ -7,16 +8,13 @@ import hudson.slaves.Cloud; import hudson.slaves.CloudProvisioningListener; import hudson.slaves.NodeProvisioner; -import org.jenkinsci.plugins.workflow.test.steps.SemaphoreStep; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.jvnet.hudson.test.TestExtension; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; -import org.mockito.verification.VerificationMode; -import javax.annotation.Nonnull; import java.util.Collection; import static org.csanchez.jenkins.plugins.kubernetes.KubernetesTestUtil.deletePods; @@ -61,7 +59,7 @@ public void onComplete(NodeProvisioner.PlannedNode plannedNode, Node node) { } @Override - public void onCommit(@Nonnull NodeProvisioner.PlannedNode plannedNode, @Nonnull Node node) { + public void onCommit(@NonNull NodeProvisioner.PlannedNode plannedNode, @NonNull Node node) { delegate.onCommit(plannedNode, node); } @@ -71,7 +69,7 @@ public void onFailure(NodeProvisioner.PlannedNode plannedNode, Throwable t) { } @Override - public void onRollback(@Nonnull NodeProvisioner.PlannedNode plannedNode, @Nonnull Node node, @Nonnull Throwable t) { + public void onRollback(@NonNull NodeProvisioner.PlannedNode plannedNode, @NonNull Node node, @NonNull Throwable t) { delegate.onRollback(plannedNode, node, t); } diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepTest.java index f023c144ee..bda6daa94f 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepTest.java @@ -1,6 +1,5 @@ package org.csanchez.jenkins.plugins.kubernetes.pipeline; -import org.csanchez.jenkins.plugins.kubernetes.pod.retention.Always; import org.csanchez.jenkins.plugins.kubernetes.pod.retention.OnFailure; import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention; import org.csanchez.jenkins.plugins.kubernetes.volumes.workspace.DynamicPVCWorkspaceVolume; @@ -11,8 +10,6 @@ import org.jvnet.hudson.test.Issue; import org.jvnet.hudson.test.JenkinsRule; -import static org.junit.Assert.*; - public class PodTemplateStepTest { @Rule public JenkinsRule rule = new JenkinsRule(); diff --git a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecoratorTest.java b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecoratorTest.java index 35ae321635..fb1d6f668f 100644 --- a/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecoratorTest.java +++ b/src/test/java/org/csanchez/jenkins/plugins/kubernetes/pod/decorator/PodDecoratorTest.java @@ -1,5 +1,6 @@ package org.csanchez.jenkins.plugins.kubernetes.pod.decorator; +import edu.umd.cs.findbugs.annotations.NonNull; import io.fabric8.kubernetes.api.model.Pod; import io.fabric8.kubernetes.api.model.PodBuilder; import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; @@ -12,13 +13,9 @@ import org.jvnet.hudson.test.JenkinsRule; import org.jvnet.hudson.test.TestExtension; import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.Spy; import org.mockito.junit.MockitoJUnit; import org.mockito.junit.MockitoRule; -import javax.annotation.Nonnull; - import static org.junit.Assert.assertEquals; import static org.mockito.Mockito.when; @@ -42,9 +39,9 @@ public void setUp() { @TestExtension("activeDecorator") public static class PodDecoratorImpl implements PodDecorator { - @Nonnull + @NonNull @Override - public Pod decorate(@Nonnull KubernetesCloud kubernetesCloud, @Nonnull Pod pod) { + public Pod decorate(@NonNull KubernetesCloud kubernetesCloud, @NonNull Pod pod) { // @formatter:off return new PodBuilder(pod) .editOrNewMetadata()