Program: 14175
Project: 14175
Buggy source:
public static JsonNode evaluateFunctions(JsonNode jsonNode,StackEntity stackEntity,Map<String,ResourceInfo> resourceInfoMap,TemplateSection templateSection) throws CloudFormationException {
  if (jsonNode == null)   return jsonNode;
  if (!jsonNode.isArray() && !jsonNode.isObject())   return jsonNode;
  ObjectMapper objectMapper=new ObjectMapper();
  if (jsonNode.isArray()) {
    ArrayNode arrayCopy=objectMapper.createArrayNode();
    for (int i=0; i < jsonNode.size(); i++) {
      JsonNode arrayElement=evaluateFunctions(jsonNode.get(i),stackEntity,resourceInfoMap,templateSection);
      arrayCopy.add(arrayElement);
    }
    return arrayCopy;
  }
  for (  IntrinsicFunction intrinsicFunction : IntrinsicFunctions.values()) {
    if ((intrinsicFunction == IntrinsicFunctions.CONDITION || intrinsicFunction == IntrinsicFunctions.AND || intrinsicFunction == IntrinsicFunctions.EQUALS || intrinsicFunction == IntrinsicFunctions.NOT || intrinsicFunction == IntrinsicFunctions.OR) && templateSection != TemplateSection.CONDITION) {
      continue;
    }
    if (intrinsicFunction == IntrinsicFunctions.IF && !(templateSection == TemplateSection.RESOURCE_METADATA || templateSection == TemplateSection.RESOURCE_PROPERTY || templateSection == TemplateSection.RESOURCE_UPDATE_POLICY)) {
      continue;
    }
    IntrinsicFunction.MatchResult matchResult=intrinsicFunction.evaluateMatch(jsonNode);
    if (matchResult.isMatch()) {
      IntrinsicFunction.ValidateResult validateResult=intrinsicFunction.validateArgTypesWherePossible(matchResult);
      return intrinsicFunction.evaluateFunction(validateResult,stackEntity,resourceInfoMap,templateSection);
    }
  }
  ObjectNode objectCopy=objectMapper.createObjectNode();
  List<String> fieldNames=Lists.newArrayList(jsonNode.fieldNames());
  for (  String key : fieldNames) {
    JsonNode objectElement=evaluateFunctions(jsonNode.get(key),stackEntity,resourceInfoMap,templateSection);
    objectCopy.put(key,objectElement);
  }
  return objectCopy;
}

Fixed version (ground truth):
public static JsonNode evaluateFunctions(JsonNode jsonNode,StackEntity stackEntity,Map<String,ResourceInfo> resourceInfoMap) throws CloudFormationException {
  if (jsonNode == null)   return jsonNode;
  if (!jsonNode.isArray() && !jsonNode.isObject())   return jsonNode;
  ObjectMapper objectMapper=new ObjectMapper();
  if (jsonNode.isArray()) {
    ArrayNode arrayCopy=objectMapper.createArrayNode();
    for (int i=0; i < jsonNode.size(); i++) {
      JsonNode arrayElement=evaluateFunctions(jsonNode.get(i),stackEntity,resourceInfoMap);
      arrayCopy.add(arrayElement);
    }
    return arrayCopy;
  }
  for (  IntrinsicFunction intrinsicFunction : IntrinsicFunctions.values()) {
    IntrinsicFunction.MatchResult matchResult=intrinsicFunction.evaluateMatch(jsonNode);
    if (matchResult.isMatch()) {
      IntrinsicFunction.ValidateResult validateResult=intrinsicFunction.validateArgTypesWherePossible(matchResult);
      return intrinsicFunction.evaluateFunction(validateResult,stackEntity,resourceInfoMap);
    }
  }
  ObjectNode objectCopy=objectMapper.createObjectNode();
  List<String> fieldNames=Lists.newArrayList(jsonNode.fieldNames());
  for (  String key : fieldNames) {
    JsonNode objectElement=evaluateFunctions(jsonNode.get(key),stackEntity,resourceInfoMap);
    objectCopy.put(key,objectElement);
  }
  return objectCopy;
}