Program: 14193
Project: 14193
Buggy source:
@Override public void create(int stepNum) throws Exception {
switch (stepNum) {
case 0:
    ServiceConfiguration configuration=Topology.lookup(Compute.class);
  DescribeSecurityGroupsType describeSecurityGroupsType=new DescribeSecurityGroupsType();
describeSecurityGroupsType.setEffectiveUserId(info.getEffectiveUserId());
DescribeSecurityGroupsResponseType describeSecurityGroupsResponseType=AsyncRequests.<DescribeSecurityGroupsType,DescribeSecurityGroupsResponseType>sendSync(configuration,describeSecurityGroupsType);
ArrayList<SecurityGroupItemType> securityGroupItemTypeArrayList=describeSecurityGroupsResponseType.getSecurityGroupInfo();
Map<String,String> nameToIdMap=Maps.newHashMap();
if (securityGroupItemTypeArrayList != null) {
for (SecurityGroupItemType securityGroupItemType : securityGroupItemTypeArrayList) {
nameToIdMap.put(securityGroupItemType.getGroupName(),securityGroupItemType.getGroupId());
}
}
AuthorizeSecurityGroupIngressType authorizeSecurityGroupIngressType=new AuthorizeSecurityGroupIngressType();
authorizeSecurityGroupIngressType.setEffectiveUserId(getResourceInfo().getEffectiveUserId());
String groupName=null;
if (properties.getGroupName() != null && !properties.getGroupName().isEmpty()) {
groupName=properties.getGroupName();
}
String groupId=null;
if (properties.getGroupId() != null && !properties.getGroupId().isEmpty()) {
groupId=properties.getGroupId();
}
if (groupName != null && !nameToIdMap.containsKey(groupName)) {
throw new ValidationErrorException("String_Node_Str" + groupName);
}
if (groupId != null && !nameToIdMap.containsValue(groupId)) {
throw new ValidationErrorException("String_Node_Str" + groupId);
}
if (groupId == null && groupName == null) {
throw new ValidationErrorException("String_Node_Str");
}
if (groupName == null) {
for (String key : nameToIdMap.keySet()) {
if (nameToIdMap.get(key).equals(groupId)) {
groupName=key;
break;
}
}
}
if (groupId == null) {
groupId=nameToIdMap.get(groupName);
}
if (!nameToIdMap.get(groupName).equals(groupId)) {
throw new ValidationErrorException("String_Node_Str" + groupId + "String_Node_Str"+ "String_Node_Str"+ groupName+ "String_Node_Str");
}
authorizeSecurityGroupIngressType.setGroupName(groupName);
authorizeSecurityGroupIngressType.setGroupId(groupId);
int fromPort=-1;
String ipProtocol=properties.getIpProtocol();
try {
fromPort=Integer.parseInt(properties.getFromPort());
}
 catch (Exception ignore) {
}
int toPort=-1;
try {
toPort=Integer.parseInt(properties.getToPort());
}
 catch (Exception ignore) {
}
String sourceSecurityGroupName=properties.getSourceSecurityGroupName();
String sourceSecurityGroupOwnerId=properties.getSourceSecurityGroupOwnerId();
if (sourceSecurityGroupOwnerId == null && sourceSecurityGroupName != null) {
sourceSecurityGroupOwnerId=stackEntity.getAccountId();
}
String cidrIp=properties.getCidrIp();
IpPermissionType ipPermissionType=new IpPermissionType(ipProtocol,fromPort,toPort);
if (sourceSecurityGroupName != null) {
ipPermissionType.setGroups(Lists.newArrayList(new UserIdGroupPairType(sourceSecurityGroupOwnerId,sourceSecurityGroupName,null)));
}
if (cidrIp != null) {
ipPermissionType.setCidrIpRanges(Lists.newArrayList(cidrIp));
}
authorizeSecurityGroupIngressType.setIpPermissions(Lists.newArrayList(ipPermissionType));
AuthorizeSecurityGroupIngressResponseType authorizeSecurityGroupIngressResponseType=AsyncRequests.<AuthorizeSecurityGroupIngressType,AuthorizeSecurityGroupIngressResponseType>sendSync(configuration,authorizeSecurityGroupIngressType);
info.setPhysicalResourceId(groupName);
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:
    ServiceConfiguration configuration=Topology.lookup(Compute.class);
  DescribeSecurityGroupsType describeSecurityGroupsType=new DescribeSecurityGroupsType();
describeSecurityGroupsType.setEffectiveUserId(info.getEffectiveUserId());
DescribeSecurityGroupsResponseType describeSecurityGroupsResponseType=AsyncRequests.<DescribeSecurityGroupsType,DescribeSecurityGroupsResponseType>sendSync(configuration,describeSecurityGroupsType);
ArrayList<SecurityGroupItemType> securityGroupItemTypeArrayList=describeSecurityGroupsResponseType.getSecurityGroupInfo();
Map<String,String> nameToIdMap=Maps.newHashMap();
if (securityGroupItemTypeArrayList != null) {
for (SecurityGroupItemType securityGroupItemType : securityGroupItemTypeArrayList) {
nameToIdMap.put(securityGroupItemType.getGroupName(),securityGroupItemType.getGroupId());
}
}
AuthorizeSecurityGroupIngressType authorizeSecurityGroupIngressType=new AuthorizeSecurityGroupIngressType();
authorizeSecurityGroupIngressType.setEffectiveUserId(getResourceInfo().getEffectiveUserId());
String groupName=null;
if (properties.getGroupName() != null && !properties.getGroupName().isEmpty()) {
groupName=properties.getGroupName();
}
String groupId=null;
if (properties.getGroupId() != null && !properties.getGroupId().isEmpty()) {
groupId=properties.getGroupId();
}
if (groupName != null && !nameToIdMap.containsKey(groupName)) {
throw new ValidationErrorException("String_Node_Str" + groupName);
}
if (groupId != null && !nameToIdMap.containsValue(groupId)) {
throw new ValidationErrorException("String_Node_Str" + groupId);
}
if (groupId == null && groupName == null) {
throw new ValidationErrorException("String_Node_Str");
}
if (groupName == null) {
for (String key : nameToIdMap.keySet()) {
if (nameToIdMap.get(key).equals(groupId)) {
groupName=key;
break;
}
}
}
if (groupId == null) {
groupId=nameToIdMap.get(groupName);
}
if (!nameToIdMap.get(groupName).equals(groupId)) {
throw new ValidationErrorException("String_Node_Str" + groupId + "String_Node_Str"+ "String_Node_Str"+ groupName+ "String_Node_Str");
}
authorizeSecurityGroupIngressType.setGroupName(groupName);
authorizeSecurityGroupIngressType.setGroupId(groupId);
int fromPort=-1;
String ipProtocol=properties.getIpProtocol();
try {
fromPort=Integer.parseInt(properties.getFromPort());
}
 catch (Exception ignore) {
}
int toPort=-1;
try {
toPort=Integer.parseInt(properties.getToPort());
}
 catch (Exception ignore) {
}
String sourceSecurityGroupName=properties.getSourceSecurityGroupName();
String sourceSecurityGroupOwnerId=properties.getSourceSecurityGroupOwnerId();
if (sourceSecurityGroupOwnerId == null && sourceSecurityGroupName != null) {
sourceSecurityGroupOwnerId=stackEntity.getAccountId();
}
String cidrIp=properties.getCidrIp();
IpPermissionType ipPermissionType=new IpPermissionType(ipProtocol,fromPort,toPort);
if (sourceSecurityGroupName != null) {
ipPermissionType.setGroups(Lists.newArrayList(new UserIdGroupPairType(sourceSecurityGroupOwnerId,sourceSecurityGroupName,null)));
}
if (cidrIp != null) {
ipPermissionType.setCidrIpRanges(Lists.newArrayList(cidrIp));
}
authorizeSecurityGroupIngressType.setIpPermissions(Lists.newArrayList(ipPermissionType));
AuthorizeSecurityGroupIngressResponseType authorizeSecurityGroupIngressResponseType=AsyncRequests.<AuthorizeSecurityGroupIngressType,AuthorizeSecurityGroupIngressResponseType>sendSync(configuration,authorizeSecurityGroupIngressType);
info.setPhysicalResourceId(info.getLogicalResourceId());
info.setReferenceValueJson(JsonHelper.getStringFromJsonNode(new TextNode(info.getPhysicalResourceId())));
break;
default :
throw new IllegalStateException("String_Node_Str" + stepNum);
}
}