Program: 14248
Project: 14248
Buggy source:
private void parseResources(Template template,JsonNode templateJsonNode) throws CloudFormationException {
  JsonNode resourcesJsonNode=JSONHelper.checkObject(templateJsonNode,TemplateSection.Resources.toString());
  List<String> resourceKeys=(List<String>)Lists.newArrayList(resourcesJsonNode.fieldNames());
  Set<String> commonParametersAndResources=Sets.intersection(Sets.newHashSet(resourceKeys),template.getReferenceMap().keySet());
  if (!commonParametersAndResources.isEmpty()) {
    throw new ValidationErrorException("String_Node_Str" + "String_Node_Str" + commonParametersAndResources);
  }
  for (  String resourceKey : resourceKeys) {
    Template.Reference reference=new Template.Reference();
    reference.setReady(false);
    reference.setReferenceName(resourceKey);
    reference.setReferenceValue(null);
    reference.setReferenceType(Template.ReferenceType.Resource);
    template.getReferenceMap().put(resourceKey,reference);
  }
  DependencyManager resourceDependencies=template.getResourceDependencyManager();
  for (  String resourceKey : resourceKeys) {
    resourceDependencies.addNode(resourceKey);
  }
  FunctionEvaluation.validateNonConditionSectionArgTypesWherePossible(resourcesJsonNode);
  Set<String> unresolvedResourceDependencies=Sets.newHashSet();
  for (  String resourceKey : resourceKeys) {
    JsonNode resourceJsonNode=resourcesJsonNode.get(resourceKey);
    JsonNode dependsOnJsonNode=resourceJsonNode.get(ResourceKey.DependsOn.toString());
    if (dependsOnJsonNode != null) {
      if (dependsOnJsonNode.isArray()) {
        for (int i=0; i < dependsOnJsonNode.size(); i++) {
          if (dependsOnJsonNode.get(i) != null && dependsOnJsonNode.get(i).isTextual()) {
            String dependeningOnResourceName=dependsOnJsonNode.get(i).textValue();
            if (!template.getReferenceMap().containsKey(dependeningOnResourceName) || template.getReferenceMap().get(dependeningOnResourceName).getReferenceType() != Template.ReferenceType.Resource) {
              unresolvedResourceDependencies.add(dependeningOnResourceName);
            }
 else {
              resourceDependencies.addDependency(resourceKey,dependeningOnResourceName);
            }
          }
 else {
            throw new ValidationErrorException("String_Node_Str");
          }
        }
      }
 else       if (dependsOnJsonNode.isTextual()) {
        String dependeningOnResourceName=dependsOnJsonNode.textValue();
        if (!template.getReferenceMap().containsKey(dependeningOnResourceName) || template.getReferenceMap().get(dependeningOnResourceName).getReferenceType() != Template.ReferenceType.Resource) {
          unresolvedResourceDependencies.add(dependeningOnResourceName);
        }
 else {
          resourceDependencies.addDependency(resourceKey,dependeningOnResourceName);
        }
      }
 else {
        throw new ValidationErrorException("String_Node_Str");
      }
    }
    Resource resource=template.getResourceMap().get(resourceKey);
    JsonNode metadataNode=JSONHelper.checkObject(resourceJsonNode,ResourceKey.Metadata.toString());
    if (metadataNode != null) {
      FunctionEvaluation.validateNonConditionSectionArgTypesWherePossible(metadataNode);
      resource.setMetadataJsonNode(metadataNode);
    }
    JsonNode propertiesNode=JSONHelper.checkObject(resourceJsonNode,ResourceKey.Properties.toString());
    if (propertiesNode != null) {
      resource.setPropertiesJsonNode(propertiesNode);
    }
    JsonNode updatePolicyNode=JSONHelper.checkObject(resourceJsonNode,ResourceKey.UpdatePolicy.toString());
    if (propertiesNode != null) {
      resource.setUpdatePolicyJsonNode(updatePolicyNode);
    }
    resource.setLogicalResourceId(resourceKey);
    resourceDependencyCrawl(resourceKey,metadataNode,resourceDependencies,template,unresolvedResourceDependencies);
    resourceDependencyCrawl(resourceKey,propertiesNode,resourceDependencies,template,unresolvedResourceDependencies);
    resourceDependencyCrawl(resourceKey,updatePolicyNode,resourceDependencies,template,unresolvedResourceDependencies);
    String deletionPolicy=JSONHelper.getString(resourceJsonNode,ResourceKey.DeletionPolicy.toString());
    if (deletionPolicy != null) {
      if (!DeletionPolicyValues.Delete.toString().equals(deletionPolicy) && !DeletionPolicyValues.Retain.equals(deletionPolicy) && !DeletionPolicyValues.Snapshot.equals(deletionPolicy)) {
        throw new ValidationErrorException("String_Node_Str" + deletionPolicy + "String_Node_Str"+ resourceKey);
      }
      if (DeletionPolicyValues.Snapshot.equals(deletionPolicy) && !resource.supportsSnapshots()) {
        throw new ValidationErrorException("String_Node_Str" + resource.getType() + "String_Node_Str");
      }
      resource.setDeletionPolicy(deletionPolicy);
    }
    String conditionKey=JSONHelper.getString(resourceJsonNode,ResourceKey.Condition.toString());
    if (conditionKey != null) {
      if (!template.getConditionMap().containsKey(conditionKey)) {
        throw new ValidationErrorException("String_Node_Str" + conditionKey + "String_Node_Str");
      }
      Template.Condition condition=template.getConditionMap().get(conditionKey);
      if (!condition.isReady()) {
        throw new ValidationErrorException("String_Node_Str" + conditionKey + "String_Node_Str");
      }
      resource.setAllowedByCondition(FunctionEvaluation.evaluateBoolean(condition.getConditionValue()));
    }
  }
  if (!unresolvedResourceDependencies.isEmpty()) {
    throw new ValidationErrorException("String_Node_Str" + unresolvedResourceDependencies + "String_Node_Str");
  }
  try {
    resourceDependencies.dependencyList();
  }
 catch (  CyclicDependencyException ex) {
    throw new ValidationErrorException("String_Node_Str" + ex.getMessage());
  }
}

Fixed version (ground truth):
private void parseResources(Template template,JsonNode templateJsonNode) throws CloudFormationException {
  JsonNode resourcesJsonNode=JSONHelper.checkObject(templateJsonNode,TemplateSection.Resources.toString());
  List<String> resourceKeys=(List<String>)Lists.newArrayList(resourcesJsonNode.fieldNames());
  Set<String> commonParametersAndResources=Sets.intersection(Sets.newHashSet(resourceKeys),template.getReferenceMap().keySet());
  if (!commonParametersAndResources.isEmpty()) {
    throw new ValidationErrorException("String_Node_Str" + "String_Node_Str" + commonParametersAndResources);
  }
  for (  String resourceKey : resourceKeys) {
    Template.Reference reference=new Template.Reference();
    reference.setReady(false);
    reference.setReferenceName(resourceKey);
    reference.setReferenceValue(null);
    reference.setReferenceType(Template.ReferenceType.Resource);
    template.getReferenceMap().put(resourceKey,reference);
  }
  DependencyManager resourceDependencies=template.getResourceDependencyManager();
  for (  String resourceKey : resourceKeys) {
    resourceDependencies.addNode(resourceKey);
  }
  Set<String> unresolvedResourceDependencies=Sets.newHashSet();
  for (  String resourceKey : resourceKeys) {
    JsonNode resourceJsonNode=resourcesJsonNode.get(resourceKey);
    JsonNode dependsOnJsonNode=resourceJsonNode.get(ResourceKey.DependsOn.toString());
    if (dependsOnJsonNode != null) {
      FunctionEvaluation.validateNonConditionSectionArgTypesWherePossible(dependsOnJsonNode);
      if (dependsOnJsonNode.isArray()) {
        for (int i=0; i < dependsOnJsonNode.size(); i++) {
          if (dependsOnJsonNode.get(i) != null && dependsOnJsonNode.get(i).isTextual()) {
            String dependeningOnResourceName=dependsOnJsonNode.get(i).textValue();
            if (!template.getReferenceMap().containsKey(dependeningOnResourceName) || template.getReferenceMap().get(dependeningOnResourceName).getReferenceType() != Template.ReferenceType.Resource) {
              unresolvedResourceDependencies.add(dependeningOnResourceName);
            }
 else {
              resourceDependencies.addDependency(resourceKey,dependeningOnResourceName);
            }
          }
 else {
            throw new ValidationErrorException("String_Node_Str");
          }
        }
      }
 else       if (dependsOnJsonNode.isTextual()) {
        String dependeningOnResourceName=dependsOnJsonNode.textValue();
        if (!template.getReferenceMap().containsKey(dependeningOnResourceName) || template.getReferenceMap().get(dependeningOnResourceName).getReferenceType() != Template.ReferenceType.Resource) {
          unresolvedResourceDependencies.add(dependeningOnResourceName);
        }
 else {
          resourceDependencies.addDependency(resourceKey,dependeningOnResourceName);
        }
      }
 else {
        throw new ValidationErrorException("String_Node_Str");
      }
    }
    Resource resource=template.getResourceMap().get(resourceKey);
    JsonNode metadataNode=JSONHelper.checkObject(resourceJsonNode,ResourceKey.Metadata.toString());
    if (metadataNode != null) {
      FunctionEvaluation.validateNonConditionSectionArgTypesWherePossible(metadataNode);
      resource.setMetadataJsonNode(metadataNode);
    }
    JsonNode propertiesNode=JSONHelper.checkObject(resourceJsonNode,ResourceKey.Properties.toString());
    if (propertiesNode != null) {
      FunctionEvaluation.validateNonConditionSectionArgTypesWherePossible(propertiesNode);
      resource.setPropertiesJsonNode(propertiesNode);
    }
    JsonNode updatePolicyNode=JSONHelper.checkObject(resourceJsonNode,ResourceKey.UpdatePolicy.toString());
    if (propertiesNode != null) {
      FunctionEvaluation.validateNonConditionSectionArgTypesWherePossible(propertiesNode);
      resource.setUpdatePolicyJsonNode(updatePolicyNode);
    }
    resource.setLogicalResourceId(resourceKey);
    resourceDependencyCrawl(resourceKey,metadataNode,resourceDependencies,template,unresolvedResourceDependencies);
    resourceDependencyCrawl(resourceKey,propertiesNode,resourceDependencies,template,unresolvedResourceDependencies);
    resourceDependencyCrawl(resourceKey,updatePolicyNode,resourceDependencies,template,unresolvedResourceDependencies);
    String deletionPolicy=JSONHelper.getString(resourceJsonNode,ResourceKey.DeletionPolicy.toString());
    if (deletionPolicy != null) {
      if (!DeletionPolicyValues.Delete.toString().equals(deletionPolicy) && !DeletionPolicyValues.Retain.equals(deletionPolicy) && !DeletionPolicyValues.Snapshot.equals(deletionPolicy)) {
        throw new ValidationErrorException("String_Node_Str" + deletionPolicy + "String_Node_Str"+ resourceKey);
      }
      if (DeletionPolicyValues.Snapshot.equals(deletionPolicy) && !resource.supportsSnapshots()) {
        throw new ValidationErrorException("String_Node_Str" + resource.getType() + "String_Node_Str");
      }
      resource.setDeletionPolicy(deletionPolicy);
    }
    String conditionKey=JSONHelper.getString(resourceJsonNode,ResourceKey.Condition.toString());
    if (conditionKey != null) {
      if (!template.getConditionMap().containsKey(conditionKey)) {
        throw new ValidationErrorException("String_Node_Str" + conditionKey + "String_Node_Str");
      }
      Template.Condition condition=template.getConditionMap().get(conditionKey);
      if (!condition.isReady()) {
        throw new ValidationErrorException("String_Node_Str" + conditionKey + "String_Node_Str");
      }
      resource.setAllowedByCondition(FunctionEvaluation.evaluateBoolean(condition.getConditionValue()));
    }
  }
  if (!unresolvedResourceDependencies.isEmpty()) {
    throw new ValidationErrorException("String_Node_Str" + unresolvedResourceDependencies + "String_Node_Str");
  }
  try {
    resourceDependencies.dependencyList();
  }
 catch (  CyclicDependencyException ex) {
    throw new ValidationErrorException("String_Node_Str" + ex.getMessage());
  }
}