Program: 133455
Project: 133455
Buggy source:
/** 
 * This operations loads a MOOSE YAML file at the specified path and returns a fully-configured set of ICE TreeComposites.
 * @param filePath The file path from which the MOOSE blocks written in YAML should be read. If the path is null or empty, the operation returns without doing any work.
 * @return The MOOSE input file specification as read from the YAML inputand stored in TreeComposites. Each TreeComposite contains both parameters and exemplar children. Any parameters in a TreeComposite are contained in a DataComponent. The id of the data component is 1.
 * @throws IOException
 */
public ArrayList<TreeComposite> loadYAML(String filePath) throws IOException {
  InputStream input=null;
  String syntaxFilePath, treeName;
  ArrayList<String> hardPathsList=null;
  ArrayList<TreeComposite> trees=new ArrayList<TreeComposite>();
  Map<String,TreeComposite> treeMap=null;
  TreeComposite oneUpTree=null;
  if (filePath == null || filePath.isEmpty()) {
    return null;
  }
  File yamlFile=new File(filePath);
  input=new FileInputStream(yamlFile);
  String projectDir=new File(yamlFile.getParent()).getParent();
  if (debugFlag) {
    logger.info("String_Node_Str" + filePath.toString());
  }
  Yaml yaml=new Yaml();
  ArrayList<?> list=(ArrayList<?>)yaml.load(input);
  if (debugFlag) {
    logger.info("String_Node_Str");
  }
  for (int i=0; i < list.size(); i++) {
    Block block=new YAMLBlock();
    block.loadFromMap((Map<String,Object>)list.get(i));
    setFileEntries(block,projectDir);
    block.active=true;
    trees.add(block.toTreeComposite());
  }
  try {
    input.close();
  }
 catch (  IOException e) {
    logger.error(getClass().getName() + "String_Node_Str",e);
  }
  ArrayList<String> topLevelNodes=new ArrayList<String>();
  for (  TreeComposite node : trees) {
    topLevelNodes.add(node.getName());
  }
  treeMap=new HashMap<String,TreeComposite>();
  Stack<TreeComposite> treeStack=new Stack<TreeComposite>();
  treeStack.push(null);
  for (  TreeComposite tree : trees) {
    treeStack.push(tree);
  }
  TreeComposite tree=treeStack.pop();
  ArrayList<TreeComposite> childExemplars;
  treeName="String_Node_Str";
  int prevNameIndex;
  while (tree != null) {
    treeName+="String_Node_Str" + tree.getName();
    treeMap.put((treeName.startsWith("String_Node_Str") ? treeName.substring(1) : treeName),tree);
    childExemplars=tree.getChildExemplars();
    for (int i=(childExemplars.size() - 1); i >= 0; i--) {
      treeStack.push(childExemplars.get(i));
    }
    if (trees.contains(treeStack.peek())) {
      treeName="String_Node_Str";
    }
 else     if (childExemplars.isEmpty()) {
      prevNameIndex=treeName.lastIndexOf("String_Node_Str" + tree.getName());
      treeName=treeName.substring(0,prevNameIndex);
      oneUpTree=treeMap.get(treeName.substring(1));
      if (oneUpTree != null && !oneUpTree.getChildExemplars().contains(treeStack.peek())) {
        prevNameIndex=treeName.lastIndexOf("String_Node_Str");
        treeName=((prevNameIndex == 0 || prevNameIndex == -1) ? treeName : treeName.substring(0,prevNameIndex));
      }
    }
    tree=treeStack.pop();
  }
  int yamlIndex=filePath.indexOf("String_Node_Str");
  syntaxFilePath=filePath.substring(0,yamlIndex) + "String_Node_Str";
  try {
    hardPathsList=loadActionSyntax(syntaxFilePath);
  }
 catch (  IOException e) {
    logger.error(getClass().getName() + "String_Node_Str",e);
  }
  TreeComposite currTree;
  boolean hasType=false;
  int typeIndex=-1;
  String cleanPath;
  ArrayList<TreeComposite> types, currChildExemplars;
  DataComponent typeParameters=null, treeParameters=null;
  for (  String path : hardPathsList) {
    cleanPath=(path.endsWith("String_Node_Str") ? path.substring(0,path.length() - 1) : path);
    currTree=treeMap.get(cleanPath);
    if (currTree != null && !(currTree.getChildExemplars().isEmpty())) {
      currChildExemplars=currTree.getChildExemplars();
      for (int i=0; i < currChildExemplars.size(); i++) {
        hasType="String_Node_Str".equals(currChildExemplars.get(i).getName());
        if (hasType) {
          typeIndex=i;
          break;
        }
      }
      if (hasType) {
        types=currTree.getChildExemplars().get(typeIndex).getChildExemplars();
        currChildExemplars.remove(typeIndex);
        currTree.setChildExemplars(currChildExemplars);
        Map<String,Entry> parameterMap=new HashMap<String,Entry>();
        for (        TreeComposite currType : types) {
          typeParameters=(DataComponent)currType.getDataNodes().get(0);
          treeParameters=(DataComponent)currTree.getDataNodes().get(0);
          parameterMap.clear();
          for (          Entry parameter : typeParameters.retrieveAllEntries()) {
            parameterMap.put(parameter.getName(),parameter);
          }
          for (          Entry currEntry : treeParameters.retrieveAllEntries()) {
            if (!parameterMap.containsKey(currEntry.getName())) {
              typeParameters.addEntry(currEntry);
            }
          }
        }
        AdaptiveTreeComposite adapTree=new AdaptiveTreeComposite(types);
        adapTree.copy(currTree);
        currTree=adapTree;
        treeMap.put(cleanPath,adapTree);
        if (!topLevelNodes.contains(currTree.getName())) {
          prevNameIndex=cleanPath.indexOf("String_Node_Str" + currTree.getName());
          treeName=cleanPath.substring(0,prevNameIndex);
          TreeComposite exemplarParent=treeMap.get(treeName);
          if (exemplarParent != null) {
            exemplarParent.addChildExemplar(currTree);
          }
        }
      }
    }
    hasType=false;
    typeIndex=-1;
  }
  ArrayList<TreeComposite> newTrees=new ArrayList<TreeComposite>();
  for (  String nodeName : topLevelNodes) {
    newTrees.add(treeMap.get(nodeName));
  }
  return newTrees;
}

Fixed version (ground truth):
/** 
 * This operations loads a MOOSE YAML file at the specified path and returns a fully-configured set of ICE TreeComposites.
 * @param filePath The file path from which the MOOSE blocks written in YAML should be read. If the path is null or empty, the operation returns without doing any work.
 * @return The MOOSE input file specification as read from the YAML inputand stored in TreeComposites. Each TreeComposite contains both parameters and exemplar children. Any parameters in a TreeComposite are contained in a DataComponent. The id of the data component is 1.
 * @throws IOException
 */
public ArrayList<TreeComposite> loadYAML(String filePath) throws IOException {
  InputStream input=null;
  String syntaxFilePath, treeName;
  ArrayList<String> hardPathsList=null;
  ArrayList<TreeComposite> trees=new ArrayList<TreeComposite>();
  Map<String,TreeComposite> treeMap=null;
  TreeComposite oneUpTree=null;
  if (filePath == null || filePath.isEmpty()) {
    return null;
  }
  File yamlFile=new File(filePath);
  input=new FileInputStream(yamlFile);
  String projectDir=new File(yamlFile.getParent()).getParent();
  if (debugFlag) {
    logger.info("String_Node_Str" + filePath.toString());
  }
  Yaml yaml=new Yaml();
  ArrayList<?> list=(ArrayList<?>)yaml.load(input);
  if (debugFlag) {
    logger.info("String_Node_Str");
  }
  if (list == null || list.isEmpty()) {
    logger.error("String_Node_Str" + yamlFile.getAbsolutePath());
    return trees;
  }
  for (int i=0; i < list.size(); i++) {
    Block block=new YAMLBlock();
    block.loadFromMap((Map<String,Object>)list.get(i));
    setFileEntries(block,projectDir);
    block.active=true;
    trees.add(block.toTreeComposite());
  }
  try {
    input.close();
  }
 catch (  IOException e) {
    logger.error(getClass().getName() + "String_Node_Str",e);
  }
  ArrayList<String> topLevelNodes=new ArrayList<String>();
  for (  TreeComposite node : trees) {
    topLevelNodes.add(node.getName());
  }
  treeMap=new HashMap<String,TreeComposite>();
  Stack<TreeComposite> treeStack=new Stack<TreeComposite>();
  treeStack.push(null);
  for (  TreeComposite tree : trees) {
    treeStack.push(tree);
  }
  TreeComposite tree=treeStack.pop();
  ArrayList<TreeComposite> childExemplars;
  treeName="String_Node_Str";
  int prevNameIndex;
  while (tree != null) {
    treeName+="String_Node_Str" + tree.getName();
    treeMap.put((treeName.startsWith("String_Node_Str") ? treeName.substring(1) : treeName),tree);
    childExemplars=tree.getChildExemplars();
    for (int i=(childExemplars.size() - 1); i >= 0; i--) {
      treeStack.push(childExemplars.get(i));
    }
    if (trees.contains(treeStack.peek())) {
      treeName="String_Node_Str";
    }
 else     if (childExemplars.isEmpty()) {
      prevNameIndex=treeName.lastIndexOf("String_Node_Str" + tree.getName());
      treeName=treeName.substring(0,prevNameIndex);
      oneUpTree=treeMap.get(treeName.substring(1));
      if (oneUpTree != null && !oneUpTree.getChildExemplars().contains(treeStack.peek())) {
        prevNameIndex=treeName.lastIndexOf("String_Node_Str");
        treeName=((prevNameIndex == 0 || prevNameIndex == -1) ? treeName : treeName.substring(0,prevNameIndex));
      }
    }
    tree=treeStack.pop();
  }
  int yamlIndex=filePath.indexOf("String_Node_Str");
  syntaxFilePath=filePath.substring(0,yamlIndex) + "String_Node_Str";
  try {
    hardPathsList=loadActionSyntax(syntaxFilePath);
  }
 catch (  IOException e) {
    logger.error(getClass().getName() + "String_Node_Str",e);
  }
  TreeComposite currTree;
  boolean hasType=false;
  int typeIndex=-1;
  String cleanPath;
  ArrayList<TreeComposite> types, currChildExemplars;
  DataComponent typeParameters=null, treeParameters=null;
  for (  String path : hardPathsList) {
    cleanPath=(path.endsWith("String_Node_Str") ? path.substring(0,path.length() - 1) : path);
    currTree=treeMap.get(cleanPath);
    if (currTree != null && !(currTree.getChildExemplars().isEmpty())) {
      currChildExemplars=currTree.getChildExemplars();
      for (int i=0; i < currChildExemplars.size(); i++) {
        hasType="String_Node_Str".equals(currChildExemplars.get(i).getName());
        if (hasType) {
          typeIndex=i;
          break;
        }
      }
      if (hasType) {
        types=currTree.getChildExemplars().get(typeIndex).getChildExemplars();
        currChildExemplars.remove(typeIndex);
        currTree.setChildExemplars(currChildExemplars);
        Map<String,Entry> parameterMap=new HashMap<String,Entry>();
        for (        TreeComposite currType : types) {
          typeParameters=(DataComponent)currType.getDataNodes().get(0);
          treeParameters=(DataComponent)currTree.getDataNodes().get(0);
          parameterMap.clear();
          for (          Entry parameter : typeParameters.retrieveAllEntries()) {
            parameterMap.put(parameter.getName(),parameter);
          }
          for (          Entry currEntry : treeParameters.retrieveAllEntries()) {
            if (!parameterMap.containsKey(currEntry.getName())) {
              typeParameters.addEntry(currEntry);
            }
          }
        }
        AdaptiveTreeComposite adapTree=new AdaptiveTreeComposite(types);
        adapTree.copy(currTree);
        currTree=adapTree;
        treeMap.put(cleanPath,adapTree);
        if (!topLevelNodes.contains(currTree.getName())) {
          prevNameIndex=cleanPath.indexOf("String_Node_Str" + currTree.getName());
          treeName=cleanPath.substring(0,prevNameIndex);
          TreeComposite exemplarParent=treeMap.get(treeName);
          if (exemplarParent != null) {
            exemplarParent.addChildExemplar(currTree);
          }
        }
      }
    }
    hasType=false;
    typeIndex=-1;
  }
  ArrayList<TreeComposite> newTrees=new ArrayList<TreeComposite>();
  for (  String nodeName : topLevelNodes) {
    newTrees.add(treeMap.get(nodeName));
  }
  return newTrees;
}