Skip to content
Permalink
Browse files
Added test to catch null pointer error when a build has no labels. Fi…
…xed the null pointer error. This is a fix for [JENKINS-10467]
  • Loading branch information
beckje01 committed Jul 27, 2011
1 parent 86e0902 commit e38d523e522ac233a2c7109364fd86b7e4862a1d
Showing 2 changed files with 10 additions and 1 deletion.
@@ -124,7 +124,7 @@ public SlaveTemplate getTemplate(String ami) {
*/
public SlaveTemplate getTemplate(Label label) {
for (SlaveTemplate t : templates)
if(label.matches(t.getLabelSet()))
if(label == null || label.matches(t.getLabelSet()))
return t;
return null;
}
@@ -39,5 +39,14 @@ public void testLabelExpression() throws Exception{
assertEquals(false, ac.canProvision(Label.parseExpression("aaa || bbb")));
assertEquals(false, ac.canProvision(Label.parseExpression("aaa || bbb")));
}

public void testEmptyLabel() throws Exception{
SlaveTemplate temp = new SlaveTemplate("ami", "foo", "22", InstanceType.LARGE, "", "foo ami", "bar", "aaa", "10", "rrr", "fff", "-Xmx1g");
List<SlaveTemplate> templates = new ArrayList<SlaveTemplate>();
templates.add(temp);
ac = new AmazonEC2Cloud(AwsRegion.US_EAST_1, "abc", "def", "ghi", "3", templates);

assertEquals(true, ac.canProvision(null));
}

}

0 comments on commit e38d523

Please sign in to comment.