Program: 14191
Project: 14191
Buggy source:
@Override public void create(int stepNum) throws Exception {
switch (stepNum) {
case 0:
    if (properties.getAlarmName() == null) {
      properties.setAlarmName(getStackEntity().getStackName() + "String_Node_Str" + info.getLogicalResourceId()+ "String_Node_Str"+ Crypto.generateAlphanumericId(12,"String_Node_Str"));
    }
  ServiceConfiguration configuration=Topology.lookup(CloudWatch.class);
DescribeAlarmsType describeAlarmsType=new DescribeAlarmsType();
AlarmNames alarmNames=new AlarmNames();
alarmNames.setMember(Lists.newArrayList(properties.getAlarmName()));
describeAlarmsType.setAlarmNames(alarmNames);
describeAlarmsType.setEffectiveUserId(info.getEffectiveUserId());
DescribeAlarmsResponseType describeAlarmsResponseType=AsyncRequests.<DescribeAlarmsType,DescribeAlarmsResponseType>sendSync(configuration,describeAlarmsType);
if (describeAlarmsResponseType.getDescribeAlarmsResult() != null && describeAlarmsResponseType.getDescribeAlarmsResult().getMetricAlarms() != null && describeAlarmsResponseType.getDescribeAlarmsResult().getMetricAlarms().getMember() != null && describeAlarmsResponseType.getDescribeAlarmsResult().getMetricAlarms().getMember().size() > 0) {
throw new ValidationErrorException("String_Node_Str" + properties.getAlarmName() + "String_Node_Str");
}
PutMetricAlarmType putMetricAlarmType=new PutMetricAlarmType();
putMetricAlarmType.setEffectiveUserId(info.getEffectiveUserId());
putMetricAlarmType.setActionsEnabled(properties.getActionsEnabled() == null ? Boolean.TRUE : properties.getActionsEnabled());
if (properties.getAlarmActions() != null) {
ResourceList alarmActions=new ResourceList();
ArrayList<String> alarmActionsMember=Lists.newArrayList(properties.getAlarmActions());
alarmActions.setMember(alarmActionsMember);
putMetricAlarmType.setAlarmActions(alarmActions);
}
putMetricAlarmType.setAlarmDescription(properties.getAlarmDescription());
putMetricAlarmType.setAlarmName(properties.getAlarmName());
putMetricAlarmType.setComparisonOperator(properties.getComparisonOperator());
if (properties.getDimensions() != null) {
Dimensions dimensions=new Dimensions();
ArrayList<Dimension> dimensionsMember=Lists.newArrayList();
for (CloudWatchMetricDimension cloudWatchMetricDimension : properties.getDimensions()) {
Dimension dimension=new Dimension();
dimension.setName(cloudWatchMetricDimension.getName());
dimension.setValue(cloudWatchMetricDimension.getValue());
dimensionsMember.add(dimension);
}
dimensions.setMember(dimensionsMember);
putMetricAlarmType.setDimensions(dimensions);
}
putMetricAlarmType.setEvaluationPeriods(properties.getEvaluationPeriods());
if (properties.getInsufficientDataActions() != null) {
ResourceList insufficientDataActions=new ResourceList();
ArrayList<String> insufficientDataActionsMember=Lists.newArrayList(properties.getInsufficientDataActions());
insufficientDataActions.setMember(insufficientDataActionsMember);
putMetricAlarmType.setInsufficientDataActions(insufficientDataActions);
}
putMetricAlarmType.setMetricName(properties.getMetricName());
putMetricAlarmType.setNamespace(properties.getNamespace());
if (properties.getOkActions() != null) {
ResourceList okActions=new ResourceList();
ArrayList<String> okActionsMember=Lists.newArrayList(properties.getOkActions());
okActions.setMember(okActionsMember);
putMetricAlarmType.setOkActions(okActions);
}
putMetricAlarmType.setPeriod(properties.getPeriod());
putMetricAlarmType.setStatistic(properties.getStatistic());
putMetricAlarmType.setThreshold(properties.getThreshold());
putMetricAlarmType.setUnit(properties.getUnit());
AsyncRequests.<PutMetricAlarmType,PutMetricAlarmResponseType>sendSync(configuration,putMetricAlarmType);
info.setPhysicalResourceId(properties.getAlarmName());
info.setReferenceValueJson(JsonHelper.getStringFromJsonNode(new TextNode(info.getPhysicalResourceId())));
break;
default :
throw new IllegalStateException("String_Node_Str" + stepNum);
}
}

Fixed version (ground truth):
@Override public void create(int stepNum) throws Exception {
switch (stepNum) {
case 0:
    if (properties.getAlarmName() == null) {
      properties.setAlarmName(getDefaultPhysicalResourceId());
    }
  ServiceConfiguration configuration=Topology.lookup(CloudWatch.class);
DescribeAlarmsType describeAlarmsType=new DescribeAlarmsType();
AlarmNames alarmNames=new AlarmNames();
alarmNames.setMember(Lists.newArrayList(properties.getAlarmName()));
describeAlarmsType.setAlarmNames(alarmNames);
describeAlarmsType.setEffectiveUserId(info.getEffectiveUserId());
DescribeAlarmsResponseType describeAlarmsResponseType=AsyncRequests.<DescribeAlarmsType,DescribeAlarmsResponseType>sendSync(configuration,describeAlarmsType);
if (describeAlarmsResponseType.getDescribeAlarmsResult() != null && describeAlarmsResponseType.getDescribeAlarmsResult().getMetricAlarms() != null && describeAlarmsResponseType.getDescribeAlarmsResult().getMetricAlarms().getMember() != null && describeAlarmsResponseType.getDescribeAlarmsResult().getMetricAlarms().getMember().size() > 0) {
throw new ValidationErrorException("String_Node_Str" + properties.getAlarmName() + "String_Node_Str");
}
PutMetricAlarmType putMetricAlarmType=new PutMetricAlarmType();
putMetricAlarmType.setEffectiveUserId(info.getEffectiveUserId());
putMetricAlarmType.setActionsEnabled(properties.getActionsEnabled() == null ? Boolean.TRUE : properties.getActionsEnabled());
if (properties.getAlarmActions() != null) {
ResourceList alarmActions=new ResourceList();
ArrayList<String> alarmActionsMember=Lists.newArrayList(properties.getAlarmActions());
alarmActions.setMember(alarmActionsMember);
putMetricAlarmType.setAlarmActions(alarmActions);
}
putMetricAlarmType.setAlarmDescription(properties.getAlarmDescription());
putMetricAlarmType.setAlarmName(properties.getAlarmName());
putMetricAlarmType.setComparisonOperator(properties.getComparisonOperator());
if (properties.getDimensions() != null) {
Dimensions dimensions=new Dimensions();
ArrayList<Dimension> dimensionsMember=Lists.newArrayList();
for (CloudWatchMetricDimension cloudWatchMetricDimension : properties.getDimensions()) {
Dimension dimension=new Dimension();
dimension.setName(cloudWatchMetricDimension.getName());
dimension.setValue(cloudWatchMetricDimension.getValue());
dimensionsMember.add(dimension);
}
dimensions.setMember(dimensionsMember);
putMetricAlarmType.setDimensions(dimensions);
}
putMetricAlarmType.setEvaluationPeriods(properties.getEvaluationPeriods());
if (properties.getInsufficientDataActions() != null) {
ResourceList insufficientDataActions=new ResourceList();
ArrayList<String> insufficientDataActionsMember=Lists.newArrayList(properties.getInsufficientDataActions());
insufficientDataActions.setMember(insufficientDataActionsMember);
putMetricAlarmType.setInsufficientDataActions(insufficientDataActions);
}
putMetricAlarmType.setMetricName(properties.getMetricName());
putMetricAlarmType.setNamespace(properties.getNamespace());
if (properties.getOkActions() != null) {
ResourceList okActions=new ResourceList();
ArrayList<String> okActionsMember=Lists.newArrayList(properties.getOkActions());
okActions.setMember(okActionsMember);
putMetricAlarmType.setOkActions(okActions);
}
putMetricAlarmType.setPeriod(properties.getPeriod());
putMetricAlarmType.setStatistic(properties.getStatistic());
putMetricAlarmType.setThreshold(properties.getThreshold());
putMetricAlarmType.setUnit(properties.getUnit());
AsyncRequests.<PutMetricAlarmType,PutMetricAlarmResponseType>sendSync(configuration,putMetricAlarmType);
info.setPhysicalResourceId(properties.getAlarmName());
info.setReferenceValueJson(JsonHelper.getStringFromJsonNode(new TextNode(info.getPhysicalResourceId())));
break;
default :
throw new IllegalStateException("String_Node_Str" + stepNum);
}
}