diff --git a/pom.xml b/pom.xml index 67f392f9dc..470545558e 100644 --- a/pom.xml +++ b/pom.xml @@ -50,6 +50,8 @@ false true jenkinsci/${project.artifactId}-plugin + Max + Low 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 f7c05919e3..233650b698 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerEnvVar.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerEnvVar.java @@ -2,6 +2,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.csanchez.jenkins.plugins.kubernetes.model.KeyValueEnvVar; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -13,6 +14,7 @@ /** * Deprecated, use KeyValueEnvVar */ +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") @Deprecated public class ContainerEnvVar extends KeyValueEnvVar { diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe.java index 172126d7f6..da545ffe42 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ContainerLivenessProbe.java @@ -8,10 +8,14 @@ import java.io.Serializable; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Created by fabricio.leotti on 26/04/17. */ +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class ContainerLivenessProbe extends AbstractDescribableImpl implements Serializable { + private String execArgs; private int timeoutSeconds; private int initialDelaySeconds; 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 ecb2712a51..4dd242e668 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesCloud.java @@ -152,6 +152,9 @@ public KubernetesCloud(String name) { * @param source Source Kubernetes cloud implementation * @since 0.13 */ + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Problem raised for calling unmarshal. Ignoring the " + + "warning cause it leads to too many changes, with " + + "unclear impact.") public KubernetesCloud(@NonNull String name, @NonNull KubernetesCloud source) { super(name); XStream2 xs = new XStream2(); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesComputer.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesComputer.java index e96c181910..b7882e8c49 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesComputer.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesComputer.java @@ -31,6 +31,8 @@ import java.util.logging.Level; import java.util.logging.Logger; +import edu.umd.cs.findbugs.annotations.NonNull; + /** * @author Carlos Sanchez carlos@apache.org */ @@ -151,14 +153,30 @@ public String toString() { } @Override + @NonNull public ACL getACL() { final ACL base = super.getACL(); - return new ACL() { - @Override - public boolean hasPermission(Authentication a, Permission permission) { - return permission == Computer.CONFIGURE ? false : base.hasPermission(a,permission); - } - }; + return new KubernetesComputerACL(base); + } + + /** + * Simple static inner class to be used by {@link #getACL()}. + * It replaces an anonymous inner class in order to fix + * SIC_INNER_SHOULD_BE_STATIC_ANON. + */ + private static final class KubernetesComputerACL extends ACL { + + private final ACL base; + + public KubernetesComputerACL(final ACL base) { + this.base = base; + } + + @Override + public boolean hasPermission(Authentication a, Permission permission) { + return permission == Computer.CONFIGURE ? false : base.hasPermission(a,permission); + } + } public void setLaunching(boolean launching) { 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 a0f381adc7..d1632674c1 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesFolderProperty.java @@ -10,6 +10,8 @@ import java.util.stream.Collectors; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import hudson.model.Job; import org.jenkinsci.Symbol; @@ -150,27 +152,15 @@ public UsagePermission(String name, boolean granted, boolean inherited) { this.inherited = inherited; } - private void setInherited(boolean inherited) { - this.inherited = inherited; - } - public boolean isInherited() { return inherited; } - private void setGranted(boolean granted) { - this.granted = granted; - } - @SuppressWarnings("unused") // by stapler/jelly public boolean isGranted() { return granted; } - private void setName(String name) { - this.name = name; - } - /** * Called from Jelly. * @@ -191,6 +181,8 @@ private static boolean userHasAdministerPermission() { return Jenkins.get().hasPermission(Jenkins.ADMINISTER); } + + @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD") private static boolean isUsageRestrictedKubernetesCloud(Cloud cloud) { if (cloud instanceof KubernetesCloud) { return ((KubernetesCloud) cloud).isUsageRestricted(); 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 3bc63e3e15..e59ddab1be 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesLauncher.java @@ -87,7 +87,7 @@ public KubernetesLauncher() { } @Override - public boolean isLaunchSupported() { + public synchronized boolean isLaunchSupported() { return !launched; } 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 877b8e1b03..7f013e52d7 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/KubernetesSlave.java @@ -1,7 +1,9 @@ package org.csanchez.jenkins.plugins.kubernetes; +import edu.umd.cs.findbugs.annotations.NonNull; import java.io.IOException; import java.util.HashSet; +import java.util.Locale; import java.util.Objects; import java.util.Optional; import java.util.Set; @@ -13,7 +15,8 @@ import java.util.logging.Logger; import edu.umd.cs.findbugs.annotations.CheckForNull; -import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import hudson.FilePath; import hudson.Util; import hudson.slaves.SlaveComputer; @@ -216,6 +219,7 @@ public String getPodName() { private String remoteFS; + @SuppressFBWarnings(value = "NM_CONFUSING", justification = "Naming confusion with a getRemoteFs method, but the latter is deprecated.") @Override public String getRemoteFS() { if (remoteFS == null) { @@ -283,7 +287,7 @@ static String getSlaveName(PodTemplate template) { return String.format("%s-%s", DEFAULT_AGENT_PREFIX, randString); } // no spaces - name = name.replaceAll("[ _]", "-").toLowerCase(); + name = name.replaceAll("[ _]", "-").toLowerCase(Locale.getDefault()); // keep it under 63 chars (62 is used to account for the '-') name = name.substring(0, Math.min(name.length(), 62 - randString.length())); String slaveName = String.format("%s-%s", name, randString); @@ -572,7 +576,7 @@ public Builder retentionStrategy(RetentionStrategy retentionStrategy) { return this; } - private RetentionStrategy determineRetentionStrategy() { + private static RetentionStrategy determineRetentionStrategy(@NonNull KubernetesCloud cloud, @NonNull PodTemplate podTemplate) { if (podTemplate.getIdleMinutes() == 0) { return new OnceRetentionStrategy(cloud.getRetentionTimeout()); } else { @@ -586,6 +590,7 @@ private RetentionStrategy determineRetentionStrategy() { * @throws IOException * @throws Descriptor.FormException */ + @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "False positive. https://github.com/spotbugs/spotbugs/issues/567") public KubernetesSlave build() throws IOException, Descriptor.FormException { Validate.notNull(podTemplate); Validate.notNull(cloud); @@ -595,11 +600,11 @@ public KubernetesSlave build() throws IOException, Descriptor.FormException { nodeDescription == null ? podTemplate.getName() : nodeDescription, cloud.name, label == null ? podTemplate.getLabel() : label, - decorateLauncher(computerLauncher == null ? new KubernetesLauncher(cloud.getJenkinsTunnel(), null) : computerLauncher), - retentionStrategy == null ? determineRetentionStrategy() : retentionStrategy); + decorateLauncher(cloud, computerLauncher == null ? new KubernetesLauncher(cloud.getJenkinsTunnel(), null) : computerLauncher), + retentionStrategy == null ? determineRetentionStrategy(cloud, podTemplate) : retentionStrategy); } - private ComputerLauncher decorateLauncher(@NonNull ComputerLauncher launcher) { + private ComputerLauncher decorateLauncher(@NonNull KubernetesCloud cloud, @NonNull ComputerLauncher launcher) { if (launcher instanceof KubernetesLauncher) { ((KubernetesLauncher) launcher).setWebSocket(cloud.isWebSocket()); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/MetricNames.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/MetricNames.java index 5d3c6d7262..5344e638d9 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/MetricNames.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/MetricNames.java @@ -1,5 +1,7 @@ package org.csanchez.jenkins.plugins.kubernetes; +import java.util.Locale; + import hudson.model.Label; public class MetricNames { @@ -17,7 +19,7 @@ public class MetricNames { public static final String PODS_LAUNCHED = PREFIX + ".pods.launched"; public static String metricNameForPodStatus(String status) { - String formattedStatus = status == null ? "null" : status.toLowerCase(); + String formattedStatus = status == null ? "null" : status.toLowerCase(Locale.getDefault()); return PREFIX + ".pods.launch.status." + formattedStatus; } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/OpenShiftTokenCredentialImpl.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/OpenShiftTokenCredentialImpl.java index f2c419f232..c8f72741ae 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/OpenShiftTokenCredentialImpl.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/OpenShiftTokenCredentialImpl.java @@ -4,6 +4,8 @@ import org.jenkinsci.plugins.plaincredentials.StringCredentials; import org.kohsuke.stapler.DataBoundConstructor; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import com.cloudbees.plugins.credentials.CredentialsScope; import com.cloudbees.plugins.credentials.impl.BaseStandardCredentials; @@ -14,6 +16,7 @@ * @deprecated Use {@link StringCredentials} * @author Andrew Block */ +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") @Deprecated public class OpenShiftTokenCredentialImpl extends BaseStandardCredentials implements TokenProducer { 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 096a2b83db..a8e915f91f 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplate.java @@ -18,6 +18,8 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import hudson.model.AbstractDescribableImpl; import hudson.model.Descriptor; import hudson.model.DescriptorVisibilityFilter; @@ -25,6 +27,7 @@ import hudson.model.Node; import hudson.model.Saveable; import hudson.model.TaskListener; + import org.apache.commons.lang.StringUtils; import org.csanchez.jenkins.plugins.kubernetes.model.TemplateEnvVar; import org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention; @@ -223,6 +226,9 @@ public PodTemplate(@CheckForNull String id) { recomputeLabelDerivedFields(); } + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Warning raised for the call to unmarshal. Ignoring as" + + " it would require too many changes and uncertain " + + "impact.") public PodTemplate(PodTemplate from) { XStream2 xs = new XStream2(); xs.unmarshal(XStream2.getDefaultDriver().createReader(new StringReader(xs.toXML(from))), this); @@ -236,6 +242,9 @@ public PodTemplate(String image, List volumes) { this(null, image, volumes); } + @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = + "Warning raised for calling the getContainers method. As " + "this current method is deprecated anyway, it is " + + "probably safer to not change it.") @Deprecated PodTemplate(String name, String image, List volumes) { this(name, volumes, Collections.emptyList()); @@ -322,6 +331,7 @@ public void setRemoteFs(String remoteFs) { } @Deprecated + @SuppressFBWarnings(value = "NM_CONFUSING", justification = "Naming confusion with a getRemoteFS method, but the current one is deprecated.") public String getRemoteFs() { return getFirstContainer().map(ContainerTemplate::getWorkingDir).orElse(ContainerTemplate.DEFAULT_WORKING_DIR); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateToolLocation.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateToolLocation.java index 3227d22d60..60e339de6f 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateToolLocation.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodTemplateToolLocation.java @@ -24,6 +24,8 @@ import java.io.Serializable; import java.util.Collection; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * Pod Template Tool Location * This class extends Jenkins DescribableList as implemented in Slave Class. Also implements Serializable interface @@ -32,6 +34,7 @@ * * @author Aytunc BEKEN */ +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class PodTemplateToolLocation extends DescribableList,NodePropertyDescriptor> implements Serializable { public PodTemplateToolLocation() {} diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodVolumes.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodVolumes.java index 2040443c10..0334ee9fb5 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodVolumes.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PodVolumes.java @@ -2,6 +2,7 @@ import java.util.List; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.fabric8.kubernetes.api.model.VolumeMount; @Deprecated @@ -11,6 +12,7 @@ public class PodVolumes { public static abstract class PodVolume extends org.csanchez.jenkins.plugins.kubernetes.volumes.PodVolume { } + @SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") @Deprecated public static class EmptyDirVolume extends org.csanchez.jenkins.plugins.kubernetes.volumes.EmptyDirVolume { @@ -24,6 +26,7 @@ protected Object readResolve() { } } + @SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") @Deprecated public static class SecretVolume extends org.csanchez.jenkins.plugins.kubernetes.volumes.SecretVolume { @@ -37,6 +40,7 @@ protected Object readResolve() { } } + @SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") @Deprecated public static class HostPathVolume extends org.csanchez.jenkins.plugins.kubernetes.volumes.HostPathVolume { @@ -50,6 +54,7 @@ protected Object readResolve() { } } + @SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") @Deprecated public static class NfsVolume extends org.csanchez.jenkins.plugins.kubernetes.volumes.NfsVolume { @@ -66,6 +71,7 @@ protected Object readResolve() { /** * @deprecated Use {@link PodVolume#volumeMountExists(String, List)} instead */ + @Deprecated public static boolean volumeMountExists(String path, List existingMounts) { return PodVolume.volumeMountExists(path, existingMounts); } @@ -73,6 +79,7 @@ public static boolean volumeMountExists(String path, List existingM /** * @deprecated Use {@link PodVolume#podVolumeExists(String,List)} instead */ + @Deprecated public static boolean podVolumeExists(String path, List existingVolumes) { for (PodVolume podVolume : existingVolumes) { if (podVolume.getMountPath().equals(path)) { diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PortMapping.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PortMapping.java index 9912668451..87f6f04324 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PortMapping.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/PortMapping.java @@ -10,7 +10,9 @@ import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class PortMapping extends AbstractDescribableImpl implements Serializable { private String name; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ServiceAccountCredential.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ServiceAccountCredential.java index 167cf1c439..f2883d12a3 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ServiceAccountCredential.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/ServiceAccountCredential.java @@ -1,7 +1,6 @@ package org.csanchez.jenkins.plugins.kubernetes; import org.jenkinsci.plugins.kubernetes.credentials.FileSystemServiceAccountCredential; -import org.jenkinsci.plugins.kubernetes.credentials.TokenProducer; import org.kohsuke.stapler.DataBoundConstructor; import com.cloudbees.plugins.credentials.CredentialsScope; @@ -14,7 +13,7 @@ * @author Nicolas De Loof */ @Deprecated -public class ServiceAccountCredential extends FileSystemServiceAccountCredential implements TokenProducer { +public class ServiceAccountCredential extends FileSystemServiceAccountCredential { private static final long serialVersionUID = 2739355565227800401L; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java index cc7112dd92..2322591c53 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerExecDecorator.java @@ -568,8 +568,9 @@ public void onClose(int i, String s) { closables.add(proc); return proc; } catch (InterruptedException ie) { + closeWatch(watch); throw new InterruptedIOException(ie.getMessage()); - } catch (Exception e) { + } catch (RuntimeException e) { closeWatch(watch); throw e; } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStepExecution.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStepExecution.java index ccff68cf3c..9d32b2e04d 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStepExecution.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/ContainerLogStepExecution.java @@ -25,10 +25,13 @@ import org.jenkinsci.plugins.workflow.steps.StepContext; import org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution; +import java.io.IOException; import java.io.PrintStream; import java.util.logging.Level; import java.util.logging.Logger; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + public class ContainerLogStepExecution extends SynchronousNonBlockingStepExecution { private static final long serialVersionUID = 5588861066775717487L; private static final transient Logger LOGGER = Logger.getLogger(ContainerLogStepExecution.class.getName()); @@ -46,7 +49,7 @@ private PrintStream logger() { StepContext context = getContext(); try { l = context.get(TaskListener.class); - } catch (Exception x) { + } catch (IOException | InterruptedException x) { LOGGER.log(Level.WARNING, "Failed to find TaskListener in context"); } finally { if (l == null) { 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 c4ee21b1ed..5af3d66929 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 @@ -3,6 +3,7 @@ import static org.csanchez.jenkins.plugins.kubernetes.pipeline.Resources.*; import java.io.Closeable; +import java.io.Serializable; import java.util.Collections; import java.util.List; import java.util.logging.Level; @@ -30,7 +31,7 @@ public class ContainerStepExecution extends StepExecution { private static final long serialVersionUID = 7634132798345235774L; - private static final transient Logger LOGGER = Logger.getLogger(ContainerStepExecution.class.getName()); + private static final Logger LOGGER = Logger.getLogger(ContainerStepExecution.class.getName()); @SuppressFBWarnings(value = "SE_TRANSIENT_FIELD_NOT_RESTORED", justification = "not needed on deserialization") private final transient ContainerStep step; @@ -95,6 +96,7 @@ public void stop(@NonNull Throwable cause) throws Exception { closeQuietly(getContext(), decorator); } + @SuppressFBWarnings("SE_BAD_FIELD") private static class ContainerExecCallback extends BodyExecutionCallback.TailCall { private static final long serialVersionUID = 6385838254761750483L; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition.java index 5acc1d4c3c..6b691da0f3 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/KubernetesAgentErrorCondition.java @@ -42,11 +42,13 @@ import org.jenkinsci.plugins.workflow.support.steps.AgentErrorCondition; import org.kohsuke.stapler.DataBoundConstructor; import org.kohsuke.stapler.DataBoundSetter; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; /** * Qualifies {@code node} blocks associated with {@link KubernetesSlave} to be retried if the node was deleted. * A more specific version of {@link AgentErrorCondition}. */ +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class KubernetesAgentErrorCondition extends ErrorCondition { private static final Logger LOGGER = Logger.getLogger(KubernetesAgentErrorCondition.class.getName()); 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 103962e3ea..6195e948ae 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 @@ -2,6 +2,8 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import hudson.ExtensionList; import hudson.Util; import hudson.model.Label; @@ -31,6 +33,7 @@ import java.util.stream.Collectors; import org.jenkinsci.plugins.pipeline.modeldefinition.agent.RetryableDeclarativeAgent; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class KubernetesDeclarativeAgent extends RetryableDeclarativeAgent { private static final Logger LOGGER = Logger.getLogger(KubernetesDeclarativeAgent.class.getName()); @@ -328,7 +331,7 @@ public Map getAsArgs() { "Ignoring containerTemplate option as containerTemplates is also defined"); } } - if (containerTemplates != null && !containerTemplates.isEmpty()) { + if (!containerTemplates.isEmpty()) { argMap.put("containers", containerTemplates); } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NamespaceAction.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NamespaceAction.java index 43e9ef6b09..3efa952046 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NamespaceAction.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/NamespaceAction.java @@ -8,13 +8,12 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.BulkChange; import hudson.model.Run; -import jenkins.model.RunAction2; /** * Use
getContext().get(PodTemplateContext.class)
instead. */ @Deprecated -public class NamespaceAction extends AbstractInvisibleRunAction2 implements RunAction2 { +public class NamespaceAction extends AbstractInvisibleRunAction2 { private static final Logger LOGGER = Logger.getLogger(NamespaceAction.class.getName()); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateAction.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateAction.java index b8eede2d0a..062c8cd641 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateAction.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateAction.java @@ -9,13 +9,12 @@ import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import hudson.BulkChange; import hudson.model.Run; -import jenkins.model.RunAction2; /** * Use
getContext().get(PodTemplateContext.class)
instead. */ @Deprecated -public class PodTemplateAction extends AbstractInvisibleRunAction2 implements RunAction2 { +public class PodTemplateAction extends AbstractInvisibleRunAction2 { private static final Logger LOGGER = Logger.getLogger(PodTemplateAction.class.getName()); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java index 22a8b81ee6..065a9b4d9d 100755 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pipeline/PodTemplateStepExecution.java @@ -43,7 +43,7 @@ public class PodTemplateStepExecution extends AbstractStepExecutionImpl { private static final long serialVersionUID = -6139090518333729333L; - private static final transient String NAME_FORMAT = "%s-%s"; + private static final String NAME_FORMAT = "%s-%s"; private static /* almost final */ boolean VERBOSE = Boolean.parseBoolean(System.getProperty(PodTemplateStepExecution.class.getName() + ".verbose")); @@ -61,7 +61,7 @@ public class PodTemplateStepExecution extends AbstractStepExecutionImpl { @Override public boolean start() throws Exception { - KubernetesCloud cloud = resolveCloud(); + KubernetesCloud cloud = resolveCloud(cloudName); Run run = getContext().get(Run.class); if (cloud.isUsageRestricted()) { @@ -150,7 +150,8 @@ public boolean start() throws Exception { listener.getLogger().println("Registering template with id=" + newTemplate.getId() + ",label="+ newTemplate.getLabel()); } cloud.addDynamicTemplate(newTemplate); - BodyInvoker invoker = getContext().newBodyInvoker().withContexts(step, new PodTemplateContext(namespace, name)).withCallback(new PodTemplateCallback(newTemplate)); + BodyInvoker invoker = + getContext().newBodyInvoker().withContexts(step, new PodTemplateContext(namespace, name)).withCallback(new PodTemplateCallback(newTemplate, cloudName)); if (step.getLabel() == null) { invoker.withContext(EnvironmentExpander.merge(getContext().get(EnvironmentExpander.class), EnvironmentExpander.constant(Collections.singletonMap("POD_LABEL", label)))); } @@ -160,7 +161,7 @@ public boolean start() throws Exception { } @NonNull - private KubernetesCloud resolveCloud() throws AbortException { + private static KubernetesCloud resolveCloud(final String cloudName) throws AbortException { KubernetesCloud cloud; if (cloudName == null) { cloud = Jenkins.get().clouds.get(KubernetesCloud.class); @@ -230,7 +231,7 @@ private String checkNamespace(KubernetesCloud kubernetesCloud, @CheckForNull Pod @Override public void onResume() { try { - KubernetesCloud cloud = resolveCloud(); + KubernetesCloud cloud = resolveCloud(cloudName); TaskListener listener = getContext().get(TaskListener.class); newTemplate.setListener(listener); LOGGER.log(Level.FINE, "Re-registering template with id=" + newTemplate.getId() + " after resume"); @@ -245,14 +246,16 @@ public void onResume() { } } - private class PodTemplateCallback extends BodyExecutionCallback.TailCall { + private static class PodTemplateCallback extends BodyExecutionCallback.TailCall { private static final long serialVersionUID = 6043919968776851324L; private final PodTemplate podTemplate; + private final String cloudName; - private PodTemplateCallback(PodTemplate podTemplate) { + private PodTemplateCallback(PodTemplate podTemplate, final String cloudName) { this.podTemplate = podTemplate; + this.cloudName = cloudName; } @Override @@ -261,7 +264,7 @@ private PodTemplateCallback(PodTemplate podTemplate) { */ protected void finished(StepContext context) throws Exception { try { - KubernetesCloud cloud = resolveCloud(); + KubernetesCloud cloud = resolveCloud(cloudName); LOGGER.log(Level.FINE, () -> "Removing pod template " + podTemplate.getName() + " from cloud " + cloud.name); cloud.removeDynamicTemplate(podTemplate); diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/OnFailure.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/OnFailure.java index 594b572f01..8f3d8c090c 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/OnFailure.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/OnFailure.java @@ -8,6 +8,8 @@ import hudson.Extension; import io.fabric8.kubernetes.api.model.Pod; + +import java.util.Locale; import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; @@ -34,7 +36,7 @@ public boolean shouldDeletePod(KubernetesCloud cloud, Supplier podS) { if (pod == null || pod.getStatus() == null) { return false; } - boolean hasErrors = pod.getStatus().getPhase().toLowerCase().matches("(failed|unknown)"); + boolean hasErrors = pod.getStatus().getPhase().toLowerCase(Locale.getDefault()).matches("(failed|unknown)"); return !hasErrors; } diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java index 2606a33f7e..07e7919e14 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/pod/retention/Reaper.java @@ -45,6 +45,7 @@ import io.fabric8.kubernetes.client.WatcherException; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Map; @@ -64,7 +65,6 @@ import org.csanchez.jenkins.plugins.kubernetes.KubernetesCloud; import org.csanchez.jenkins.plugins.kubernetes.KubernetesComputer; import org.csanchez.jenkins.plugins.kubernetes.KubernetesSlave; -import org.csanchez.jenkins.plugins.kubernetes.PodTemplate; import org.csanchez.jenkins.plugins.kubernetes.PodUtils; import org.jenkinsci.plugins.kubernetes.auth.KubernetesAuthException; @@ -78,7 +78,7 @@ */ @Extension public class Reaper extends ComputerListener { - + private static final Logger LOGGER = Logger.getLogger(Reaper.class.getName()); /** @@ -106,8 +106,8 @@ public static Reaper getInstance() { private final Map watchers = new ConcurrentHashMap<>(); private final LoadingCache> terminationReasons = Caffeine.newBuilder(). - expireAfterAccess(1, TimeUnit.DAYS). - build(k -> new ConcurrentSkipListSet<>()); + expireAfterAccess(1, TimeUnit.DAYS). + build(k -> new ConcurrentSkipListSet<>()); @Override public void preLaunch(Computer c, TaskListener taskListener) throws IOException, InterruptedException { @@ -174,7 +174,7 @@ private void reapAgents() { } else { LOGGER.fine(() -> ns + "/" + name + " still seems to exist, OK"); } - } catch (Exception x) { + } catch (KubernetesAuthException | IOException | RuntimeException x) { LOGGER.log(Level.WARNING, x, () -> "failed to do initial reap check for " + ns + "/" + name); } } @@ -197,12 +197,12 @@ private void watchClouds() { // close any cloud watchers that have been removed cloudNames.stream() - .map(this.watchers::get) - .filter(Objects::nonNull) - .forEach(cpw -> { - LOGGER.info(() -> "stopping pod watcher for deleted kubernetes cloud " + cpw.cloudName); - cpw.stop(); - }); + .map(this.watchers::get) + .filter(Objects::nonNull) + .forEach(cpw -> { + LOGGER.info(() -> "stopping pod watcher for deleted kubernetes cloud " + cpw.cloudName); + cpw.stop(); + }); } } @@ -225,7 +225,7 @@ private void watchCloud(@NonNull KubernetesCloud kc) { old.stop(); } LOGGER.info(() -> "set up watcher on " + kc.getDisplayName()); - } catch (Exception x) { + } catch (KubernetesAuthException | IOException | RuntimeException x) { LOGGER.log(Level.WARNING, x, () -> "failed to set up watcher on " + kc.getDisplayName()); } } @@ -253,10 +253,10 @@ private boolean isCloudPodWatcherActive(@NonNull CloudPodWatcher watcher) { private static Optional resolveNode(@NonNull Jenkins jenkins, String namespace, String name) { return new ArrayList<>(jenkins.getNodes()).stream() - .filter(KubernetesSlave.class::isInstance) - .map(KubernetesSlave.class::cast) - .filter(ks -> Objects.equals(ks.getNamespace(), namespace) && Objects.equals(ks.getPodName(), name)) - .findFirst(); + .filter(KubernetesSlave.class::isInstance) + .map(KubernetesSlave.class::cast) + .filter(ks -> Objects.equals(ks.getNamespace(), namespace) && Objects.equals(ks.getPodName(), name)) + .findFirst(); } /** @@ -316,7 +316,8 @@ public void eventReceived(Action action, Pod pod) { Listeners.notify(Listener.class, true, listener -> { try { - listener.onEvent(action, optionalNode.get(), pod, terminationReasons.get(optionalNode.get().getNodeName())); + Set terminationReasons = Reaper.this.terminationReasons.get(optionalNode.get().getNodeName()); + listener.onEvent(action, optionalNode.get(), pod, terminationReasons != null ? terminationReasons : Collections.emptySet()); } catch (Exception x) { LOGGER.log(Level.WARNING, "Listener " + listener + " failed for " + ns + "/" + name, x); } @@ -528,4 +529,4 @@ public void onChange(Saveable o, XmlFile file) { } } } -} +} \ No newline at end of file diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume.java index 3863895225..3fdc98d4c2 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/ConfigMapVolume.java @@ -33,8 +33,9 @@ import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeBuilder; import org.kohsuke.stapler.DataBoundSetter; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; - +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class ConfigMapVolume extends PodVolume { private String mountPath; private String subPath; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/DynamicPVCVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/DynamicPVCVolume.java index 48db86a244..aa48b5e6cc 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/DynamicPVCVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/DynamicPVCVolume.java @@ -12,6 +12,7 @@ import java.util.Objects; import java.util.UUID; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.DoNotUse; @@ -22,6 +23,7 @@ /** * Implements a dynamic PVC volume, that is created before the agent pod is created, and terminated afterwards. */ +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class DynamicPVCVolume extends PodVolume implements DynamicPVC { private String id; private String storageClassName; 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 86e8e0f2f3..79e807a5dc 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 @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -34,6 +35,7 @@ import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeBuilder; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class EmptyDirVolume extends PodVolume { private static final String DEFAULT_MEDIUM = ""; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume.java index cd6e39361b..76ef260866 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/HostPathVolume.java @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -34,6 +35,7 @@ import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeBuilder; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class HostPathVolume extends PodVolume { private String mountPath; private String hostPath; 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 2d6b2488bb..dea04db571 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 @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -34,6 +35,7 @@ import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeBuilder; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class NfsVolume extends PodVolume { private String mountPath; private String serverAddress; 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 7c8378e3b2..a4a656c27b 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 @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -34,6 +35,7 @@ import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeBuilder; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class PersistentVolumeClaim extends PodVolume { private String mountPath; private String claimName; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume.java index 150eb93f27..12b18053a5 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/SecretVolume.java @@ -28,12 +28,15 @@ import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + import hudson.Extension; import hudson.model.Descriptor; import io.fabric8.kubernetes.api.model.SecretVolumeSource; import io.fabric8.kubernetes.api.model.Volume; import io.fabric8.kubernetes.api.model.VolumeBuilder; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class SecretVolume extends PodVolume { private String mountPath; private String secretName; 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 e359f9ffbc..e67f0faded 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 @@ -11,6 +11,7 @@ import io.fabric8.kubernetes.client.KubernetesClient; import java.util.Objects; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.csanchez.jenkins.plugins.kubernetes.volumes.DynamicPVC; import org.csanchez.jenkins.plugins.kubernetes.volumes.PVCVolumeUtils; import org.jenkinsci.Symbol; @@ -23,6 +24,7 @@ /** * @author runzexia */ +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class DynamicPVCWorkspaceVolume extends WorkspaceVolume implements DynamicPVC { private String storageClassName; private String requestsSize; 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 a7bb544002..a0138e302c 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 @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -36,6 +37,7 @@ import java.util.Objects; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class EmptyDirWorkspaceVolume extends WorkspaceVolume { private static final String DEFAULT_MEDIUM = ""; diff --git a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/HostPathWorkspaceVolume.java b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/HostPathWorkspaceVolume.java index 533dfd28b4..d4ebcc207d 100644 --- a/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/HostPathWorkspaceVolume.java +++ b/src/main/java/org/csanchez/jenkins/plugins/kubernetes/volumes/workspace/HostPathWorkspaceVolume.java @@ -34,6 +34,9 @@ import java.util.Objects; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class HostPathWorkspaceVolume extends WorkspaceVolume { private String hostPath; 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 a1a0c09c2e..3137991c88 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 @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -36,6 +37,7 @@ import java.util.Objects; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class NfsWorkspaceVolume extends WorkspaceVolume { private String serverAddress; private String serverPath; 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 ce478f5012..abea9a0e7f 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 @@ -26,6 +26,7 @@ import edu.umd.cs.findbugs.annotations.CheckForNull; import edu.umd.cs.findbugs.annotations.NonNull; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import org.jenkinsci.Symbol; import org.kohsuke.stapler.DataBoundConstructor; @@ -36,6 +37,7 @@ import java.util.Objects; +@SuppressFBWarnings(value = "SE_NO_SERIALVERSIONID", justification = "Serialization happens exclusively through XStream and not Java Serialization.") public class PersistentVolumeClaimWorkspaceVolume extends WorkspaceVolume { private String claimName; @CheckForNull