Program: 109977
Project: 109977
Buggy source:
private static ArrayList<Block> initializeBlocks() throws SurveyException {
  Map<String,Block> blockLookUp=new HashMap<String,Block>();
  setBlockMaps(blockLookUp,topLevelBlocks);
  allBlockLookUp=new HashMap<String,Block>(blockLookUp);
  ArrayList<Block> blocks=(ArrayList<Block>)topLevelBlocks;
  int currentDepth=1;
  while (!blockLookUp.isEmpty()) {
    Iterator<String> itr=blockLookUp.keySet().iterator();
    while (itr.hasNext()) {
      String strId=itr.next();
      if (topLevelBlocks.contains(blockLookUp.get(strId))) {
        itr.remove();
        blockLookUp.remove(strId);
      }
 else {
        LOGGER.log(Level.WARN,"String_Node_Str");
        Block block=blockLookUp.get(strId);
        if (block.id.length == currentDepth + 1) {
          List<Integer> sublist=new ArrayList<Integer>();
          for (int i=0; i < block.id.length - 1; i++)           sublist.add(block.id[i]);
          Integer[] parentBlockId=sublist.toArray(new Integer[block.id.length - 1]);
          String parentBlockStr=parentBlockId[0].toString();
          for (int i=1; i < parentBlockId.length; i++)           parentBlockStr=parentBlockStr + "String_Node_Str" + parentBlockId[i].toString();
          Block parent=allBlockLookUp.get(parentBlockStr);
          int thisBlocksIndex=block.id[block.id.length - 1] - 1;
          if (parent.subBlocks == null)           parent.subBlocks=new ArrayList<Block>();
          if (parent.subBlocks.size() < thisBlocksIndex + 1)           for (int j=parent.subBlocks.size(); j <= thisBlocksIndex; j++)           parent.subBlocks.add(null);
          if (parent.subBlocks.get(thisBlocksIndex) != null)           throw new MalformedBlockException(block.strId);
          parent.subBlocks.set(thisBlocksIndex,block);
          itr.remove();
          blockLookUp.remove(strId);
        }
      }
    }
    currentDepth++;
  }
  return blocks;
}

Fixed version (ground truth):
private static ArrayList<Block> initializeBlocks() throws SurveyException {
  Map<String,Block> blockLookUp=new HashMap<String,Block>();
  setBlockMaps(blockLookUp,topLevelBlocks);
  allBlockLookUp=new HashMap<String,Block>(blockLookUp);
  ArrayList<Block> blocks=(ArrayList<Block>)topLevelBlocks;
  int currentDepth=1;
  while (!blockLookUp.isEmpty()) {
    Iterator<String> itr=blockLookUp.keySet().iterator();
    while (itr.hasNext()) {
      String strId=itr.next();
      if (topLevelBlocks.contains(blockLookUp.get(strId))) {
        itr.remove();
        blockLookUp.remove(strId);
      }
 else {
        LOGGER.log(Level.WARN,"String_Node_Str");
        Block block=blockLookUp.get(strId);
        if (block.id.length == currentDepth + 1) {
          List<Integer> sublist=new ArrayList<Integer>();
          for (int i=0; i < block.id.length - 1; i++)           sublist.add(block.id[i]);
          Integer[] parentBlockId=sublist.toArray(new Integer[block.id.length - 1]);
          String parentBlockStr=parentBlockId[0].toString();
          for (int i=1; i < parentBlockId.length; i++)           parentBlockStr=parentBlockStr + "String_Node_Str" + parentBlockId[i].toString();
          Block parent=allBlockLookUp.get(parentBlockStr);
          int thisBlocksIndex=block.id[block.id.length - 1] - 1;
          if (parent == null) {
            parent=new Block();
            parent.strId=parentBlockStr;
            parent.id=getBlockIdArray(parentBlockStr);
          }
          if (parent.subBlocks == null)           parent.subBlocks=new ArrayList<Block>();
          if (parent.subBlocks.size() < thisBlocksIndex + 1)           for (int j=parent.subBlocks.size(); j <= thisBlocksIndex; j++)           parent.subBlocks.add(null);
          if (parent.subBlocks.get(thisBlocksIndex) != null)           throw new MalformedBlockException(block.strId);
          parent.subBlocks.set(thisBlocksIndex,block);
          itr.remove();
          blockLookUp.remove(strId);
        }
      }
    }
    currentDepth++;
  }
  return blocks;
}