Skip to content

Commit

Permalink
[JENKINS-37541] Protect ourselves against deserialization with null b…
Browse files Browse the repository at this point in the history
…inding
  • Loading branch information
Vlatombe committed Aug 19, 2016
1 parent e2a2dbb commit ad1bd01
Showing 1 changed file with 10 additions and 2 deletions.
Expand Up @@ -33,6 +33,7 @@
import hudson.tasks.BuildWrapperDescriptor;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -42,10 +43,10 @@
@SuppressWarnings({"rawtypes", "unchecked"}) // inherited from BuildWrapper
public class SecretBuildWrapper extends BuildWrapper {

private final List<? extends MultiBinding<?>> bindings;
private /*almost final*/ List<? extends MultiBinding<?>> bindings;

@DataBoundConstructor public SecretBuildWrapper(List<? extends MultiBinding<?>> bindings) {
this.bindings = bindings;
this.bindings = bindings == null ? Collections.<MultiBinding<?>>emptyList() : bindings;
}

public List<? extends MultiBinding<?>> getBindings() {
Expand Down Expand Up @@ -78,6 +79,13 @@ public List<? extends MultiBinding<?>> getBindings() {
}
}

protected Object readResolve() {
if (bindings == null) {
bindings = Collections.emptyList();
}
return this;
}

@Extension public static class DescriptorImpl extends BuildWrapperDescriptor {

@Override public boolean isApplicable(AbstractProject<?, ?> item) {
Expand Down

0 comments on commit ad1bd01

Please sign in to comment.