Skip to content

Commit

Permalink
[JENKINS-57214] Always initialize yamls field.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vlatombe committed Apr 29, 2019
1 parent b9ea4ff commit f2f3d8a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import hudson.Util;
import hudson.model.AbstractDescribableImpl;
Expand Down Expand Up @@ -128,7 +127,8 @@ public class PodTemplate extends AbstractDescribableImpl<PodTemplate> implements
@Deprecated
private transient String yaml;

private List<String> yamls;
@Nonnull
private List<String> yamls = new ArrayList<>();

@CheckForNull
private PodRetention podRetention = PodRetention.getPodTemplateDefault();
Expand Down Expand Up @@ -512,7 +512,7 @@ public void setNodeProperties(List<? extends NodeProperty<?>> properties) {
this.getNodeProperties().addAll(properties);
}

@NonNull
@Nonnull
public PodTemplateToolLocation getNodeProperties(){
if( this.nodeProperties == null)
this.nodeProperties = new PodTemplateToolLocation(this);
Expand Down Expand Up @@ -619,7 +619,7 @@ public List<ContainerTemplate> getContainers() {
*/
@Restricted(NoExternalUse.class) // Tests and UI
public String getYaml() {
return yamls.isEmpty() ? null : yamls.get(0);
return yamls == null || yamls.isEmpty() ? null : yamls.get(0);
}

@DataBoundSetter
Expand All @@ -632,6 +632,7 @@ public void setYaml(String yaml) {
}
}

@Nonnull
public List<String> getYamls() {
if (yamls ==null) {
return Collections.emptyList();
Expand Down

0 comments on commit f2f3d8a

Please sign in to comment.