Skip to content

Commit

Permalink
Merge pull request #112 from jglick/NPE-JENKINS-42367
Browse files Browse the repository at this point in the history
[JENKINS-42367] Missing null check
  • Loading branch information
jglick committed Mar 2, 2017
2 parents 7e0b274 + 2ee7ab7 commit 3c87558
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -82,7 +82,7 @@

private static void addValue(Map<String, Object> values, ParameterValue parameterValue) {
Object value = parameterValue.getValue();
if (!(value instanceof Serializable)) {
if (value != null && !(value instanceof Serializable)) {
boolean canPickle = false;
for (PickleFactory pf : PickleFactory.all()) {
if (pf.writeReplace(value) != null) {
Expand Down
Expand Up @@ -60,4 +60,12 @@ public class ParamsVariableTest {
r.assertLogContains("PASS=s3cr3t", b);
}

@Issue("JENKINS-42367")
@Test public void nullValue() throws Exception {
WorkflowJob p = r.jenkins.createProject(WorkflowJob.class, "p");
p.setDefinition(new CpsFlowDefinition("echo(/TEXT=${params.TEXT}/)",true));
p.addProperty(new ParametersDefinitionProperty(new StringParameterDefinition("TEXT", "")));
r.assertLogContains("TEXT=null", r.assertBuildStatusSuccess(p.scheduleBuild2(0, new ParametersAction(new StringParameterValue("TEXT", /* not possible via UI, but to simulate other ParameterValue impls */null)))));
}

}

0 comments on commit 3c87558

Please sign in to comment.