Program: 50231
Project: 50231
Buggy source:
public void addAdditionalTaxonomyTableIntoGraph(String filename){
  String str="String_Node_Str";
  int count=0;
  HashMap<String,String> ndnames=new HashMap<String,String>();
  HashMap<String,String> parents=new HashMap<String,String>();
  Transaction tx;
  ArrayList<String> addnodes=new ArrayList<String>();
  try {
    BufferedReader br=new BufferedReader(new FileReader(filename));
    while ((str=br.readLine()) != null) {
      count+=1;
      String[] spls=str.split("String_Node_Str");
      parents.put(spls[0],spls[1]);
      String strname=spls[2];
      ndnames.put(spls[0],strname);
      IndexHits<Node> ih=nodeIndex.get("String_Node_Str",strname);
      try {
        if (ih.size() == 0) {
          addnodes.add(strname);
        }
      }
  finally {
        ih.close();
      }
      if (count % transaction_iter == 0) {
        System.out.print(count);
        System.out.print("String_Node_Str");
        System.out.print(addnodes.size());
        System.out.print("String_Node_Str");
        tx=graphDb.beginTx();
        try {
          for (int i=0; i < addnodes.size(); i++) {
            Node tnode=graphDb.createNode();
            tnode.setProperty("String_Node_Str",addnodes.get(i));
            nodeIndex.add(tnode,"String_Node_Str",addnodes.get(i));
          }
          addnodes.clear();
          tx.success();
        }
  finally {
          tx.finish();
        }
      }
    }
    br.close();
  }
 catch (  IOException ioe) {
  }
  tx=graphDb.beginTx();
  try {
    for (int i=0; i < addnodes.size(); i++) {
      Node tnode=graphDb.createNode();
      tnode.setProperty("String_Node_Str",addnodes.get(i));
      nodeIndex.add(tnode,"String_Node_Str",addnodes.get(i));
    }
    addnodes.clear();
    tx.success();
  }
  finally {
    tx.finish();
  }
  System.out.println("String_Node_Str");
  ArrayList<Node> rel_nd=new ArrayList<Node>();
  ArrayList<Node> rel_pnd=new ArrayList<Node>();
  ArrayList<String> rel_cid=new ArrayList<String>();
  ArrayList<String> rel_pid=new ArrayList<String>();
  try {
    count=0;
    BufferedReader br=new BufferedReader(new FileReader(filename));
    boolean verbose=false;
    while ((str=br.readLine()) != null) {
      count+=1;
      String[] spls=str.split("String_Node_Str");
      String strname=spls[2];
      String strparentname="String_Node_Str";
      if (spls[1].compareTo("String_Node_Str") != 0)       strparentname=ndnames.get(spls[1]);
      if (spls[1].compareTo("String_Node_Str") == 0)       continue;
      if (verbose)       System.out.println(str);
      ArrayList<String> path1=new ArrayList<String>();
      boolean going=true;
      boolean badpath=false;
      String cur=parents.get(spls[0]);
      if (verbose)       System.out.println("String_Node_Str" + cur);
      while (going == true) {
        if (cur == null) {
          going=false;
          badpath=true;
        }
 else         if (cur.compareTo("String_Node_Str") == 0) {
          going=false;
        }
 else {
          if (verbose)           System.out.println("String_Node_Str" + cur);
          path1.add(ndnames.get(cur));
          cur=parents.get(cur);
        }
      }
      if (badpath == true)       continue;
      Node matchnode=null;
      HashMap<Node,ArrayList<Integer>> itemcounts=new HashMap<Node,ArrayList<Integer>>();
      int bestcount=LARGE + LARGE;
      Node bestitem=null;
      ArrayList<String> bestpath=null;
      ArrayList<Node> bestpathitems=null;
      IndexHits<Node> hits=nodeIndex.get("String_Node_Str",strname);
      ArrayList<String> path2=null;
      ArrayList<Node> path2items=null;
      boolean first=true;
      try {
        for (        Node node : hits) {
          path2=new ArrayList<String>();
          path2items=new ArrayList<Node>();
          for (          Node currentNode : CHILDOF_TRAVERSAL.traverse(node).nodes()) {
            if (verbose)             System.out.println("String_Node_Str" + ((String)currentNode.getProperty("String_Node_Str")));
            if (((String)currentNode.getProperty("String_Node_Str")).compareTo(strname) != 0) {
              path2.add((String)currentNode.getProperty("String_Node_Str"));
              path2items.add(currentNode);
              if (verbose)               System.out.println((String)currentNode.getProperty("String_Node_Str"));
            }
          }
          itemcounts.put(node,stepsToMatch(path1,path2));
          if (verbose)           System.out.println(sum(itemcounts.get(node)));
          if (sum(itemcounts.get(node)) < bestcount || first == true) {
            first=false;
            bestcount=sum(itemcounts.get(node));
            bestitem=node;
            bestpath=new ArrayList<String>(path2);
            bestpathitems=new ArrayList<Node>(path2items);
          }
          path2.clear();
          path2items.clear();
          if (verbose)           System.out.println(bestcount);
          if (verbose)           System.out.println("String_Node_Str" + bestpath.get(1));
        }
      }
  finally {
        hits.close();
      }
      itemcounts.clear();
      matchnode=bestitem;
      if (spls[1].compareTo("String_Node_Str") != 0) {
        Node matchnodeparent=null;
        for (int i=0; i < bestpath.size(); i++) {
          if (bestpath.get(i).compareTo(strparentname) == 0) {
            matchnodeparent=bestpathitems.get(i);
          }
          if (verbose)           System.out.println("String_Node_Str" + bestpath.get(i) + "String_Node_Str"+ strparentname);
        }
        if (matchnodeparent == null) {
          IndexHits<Node> hits2=nodeIndex.get("String_Node_Str",strparentname);
          try {
            for (            Node node2 : hits2) {
              matchnodeparent=node2;
            }
          }
  finally {
            hits2.close();
          }
        }
        rel_nd.add(matchnode);
        rel_pnd.add(matchnodeparent);
        rel_cid.add(spls[0]);
        rel_pid.add(spls[1]);
      }
      if (count % transaction_iter == 0) {
        System.out.println(count);
        tx=graphDb.beginTx();
        try {
          for (int i=0; i < rel_nd.size(); i++) {
            Relationship rel=rel_nd.get(i).createRelationshipTo(rel_pnd.get(i),RelTypes.CHILDOF);
            rel.setProperty("String_Node_Str",filename);
            rel.setProperty("String_Node_Str",rel_cid.get(i));
            rel.setProperty("String_Node_Str",rel_pid.get(i));
          }
          rel_nd.clear();
          rel_pnd.clear();
          rel_cid.clear();
          rel_pid.clear();
          tx.success();
        }
  finally {
          tx.finish();
        }
      }
      path1.clear();
    }
    tx=graphDb.beginTx();
    try {
      for (int i=0; i < rel_nd.size(); i++) {
        Relationship rel=rel_nd.get(i).createRelationshipTo(rel_pnd.get(i),RelTypes.CHILDOF);
        rel.setProperty("String_Node_Str",filename);
        rel.setProperty("String_Node_Str",rel_cid.get(i));
        rel.setProperty("String_Node_Str",rel_pid.get(i));
      }
      rel_nd.clear();
      rel_pnd.clear();
      rel_cid.clear();
      rel_pid.clear();
      tx.success();
    }
  finally {
      tx.finish();
    }
    br.close();
  }
 catch (  IOException ioe) {
  }
}

Fixed version (ground truth):
public void addAdditionalTaxonomyTableIntoGraph(String filename){
  String str="String_Node_Str";
  int count=0;
  HashMap<String,String> ndnames=new HashMap<String,String>();
  HashMap<String,String> parents=new HashMap<String,String>();
  Transaction tx;
  ArrayList<String> addnodes=new ArrayList<String>();
  try {
    BufferedReader br=new BufferedReader(new FileReader(filename));
    while ((str=br.readLine()) != null) {
      count+=1;
      String[] spls=str.split("String_Node_Str");
      parents.put(spls[0],spls[1]);
      String strname=spls[2];
      ndnames.put(spls[0],strname);
      IndexHits<Node> ih=nodeIndex.get("String_Node_Str",strname);
      try {
        if (ih.size() == 0) {
          addnodes.add(strname);
        }
      }
  finally {
        ih.close();
      }
      if (count % transaction_iter == 0) {
        System.out.print(count);
        System.out.print("String_Node_Str");
        System.out.print(addnodes.size());
        System.out.print("String_Node_Str");
        tx=graphDb.beginTx();
        try {
          for (int i=0; i < addnodes.size(); i++) {
            Node tnode=graphDb.createNode();
            tnode.setProperty("String_Node_Str",addnodes.get(i));
            nodeIndex.add(tnode,"String_Node_Str",addnodes.get(i));
          }
          addnodes.clear();
          tx.success();
        }
  finally {
          tx.finish();
        }
      }
    }
    br.close();
  }
 catch (  IOException ioe) {
  }
  tx=graphDb.beginTx();
  try {
    for (int i=0; i < addnodes.size(); i++) {
      Node tnode=graphDb.createNode();
      tnode.setProperty("String_Node_Str",addnodes.get(i));
      nodeIndex.add(tnode,"String_Node_Str",addnodes.get(i));
    }
    addnodes.clear();
    tx.success();
  }
  finally {
    tx.finish();
  }
  System.out.println("String_Node_Str");
  ArrayList<Node> rel_nd=new ArrayList<Node>();
  ArrayList<Node> rel_pnd=new ArrayList<Node>();
  ArrayList<String> rel_cid=new ArrayList<String>();
  ArrayList<String> rel_pid=new ArrayList<String>();
  try {
    count=0;
    BufferedReader br=new BufferedReader(new FileReader(filename));
    boolean verbose=false;
    while ((str=br.readLine()) != null) {
      count+=1;
      String[] spls=str.split("String_Node_Str");
      String strname=spls[2];
      String strparentname="String_Node_Str";
      if (spls[1].compareTo("String_Node_Str") != 0)       strparentname=ndnames.get(spls[1]);
      if (spls[1].compareTo("String_Node_Str") == 0)       continue;
      if (verbose)       System.out.println(str);
      ArrayList<String> path1=new ArrayList<String>();
      boolean going=true;
      boolean badpath=false;
      String cur=parents.get(spls[0]);
      if (verbose)       System.out.println("String_Node_Str" + cur);
      while (going == true) {
        if (cur == null) {
          going=false;
          badpath=true;
          System.out.println("String_Node_Str" + spls[0]);
        }
 else         if (cur.compareTo("String_Node_Str") == 0) {
          going=false;
        }
 else {
          if (verbose)           System.out.println("String_Node_Str" + cur);
          path1.add(ndnames.get(cur));
          cur=parents.get(cur);
        }
      }
      if (badpath == true)       continue;
      Node matchnode=null;
      HashMap<Node,ArrayList<Integer>> itemcounts=new HashMap<Node,ArrayList<Integer>>();
      int bestcount=LARGE + LARGE;
      Node bestitem=null;
      ArrayList<String> bestpath=null;
      ArrayList<Node> bestpathitems=null;
      IndexHits<Node> hits=nodeIndex.get("String_Node_Str",strname);
      ArrayList<String> path2=null;
      ArrayList<Node> path2items=null;
      boolean first=true;
      try {
        for (        Node node : hits) {
          path2=new ArrayList<String>();
          path2items=new ArrayList<Node>();
          for (          Node currentNode : CHILDOF_TRAVERSAL.traverse(node).nodes()) {
            if (verbose)             System.out.println("String_Node_Str" + ((String)currentNode.getProperty("String_Node_Str")));
            if (((String)currentNode.getProperty("String_Node_Str")).compareTo(strname) != 0) {
              path2.add((String)currentNode.getProperty("String_Node_Str"));
              path2items.add(currentNode);
              if (verbose)               System.out.println((String)currentNode.getProperty("String_Node_Str"));
            }
          }
          itemcounts.put(node,stepsToMatch(path1,path2));
          if (verbose)           System.out.println(sum(itemcounts.get(node)));
          if (sum(itemcounts.get(node)) < bestcount || first == true) {
            first=false;
            bestcount=sum(itemcounts.get(node));
            bestitem=node;
            bestpath=new ArrayList<String>(path2);
            bestpathitems=new ArrayList<Node>(path2items);
          }
          path2.clear();
          path2items.clear();
          if (verbose)           System.out.println(bestcount);
          if (verbose)           System.out.println("String_Node_Str" + bestpath.get(1));
        }
      }
  finally {
        hits.close();
      }
      itemcounts.clear();
      matchnode=bestitem;
      if (spls[1].compareTo("String_Node_Str") != 0) {
        Node matchnodeparent=null;
        for (int i=0; i < bestpath.size(); i++) {
          if (bestpath.get(i).compareTo(strparentname) == 0) {
            matchnodeparent=bestpathitems.get(i);
          }
          if (verbose)           System.out.println("String_Node_Str" + bestpath.get(i) + "String_Node_Str"+ strparentname);
        }
        if (matchnodeparent == null) {
          IndexHits<Node> hits2=nodeIndex.get("String_Node_Str",strparentname);
          try {
            for (            Node node2 : hits2) {
              matchnodeparent=node2;
            }
          }
  finally {
            hits2.close();
          }
        }
        rel_nd.add(matchnode);
        rel_pnd.add(matchnodeparent);
        rel_cid.add(spls[0]);
        rel_pid.add(spls[1]);
      }
      if (count % transaction_iter == 0) {
        System.out.println(count);
        tx=graphDb.beginTx();
        try {
          for (int i=0; i < rel_nd.size(); i++) {
            Relationship rel=rel_nd.get(i).createRelationshipTo(rel_pnd.get(i),RelTypes.TAXCHILDOF);
            rel.setProperty("String_Node_Str",filename);
            rel.setProperty("String_Node_Str",rel_cid.get(i));
            rel.setProperty("String_Node_Str",rel_pid.get(i));
          }
          rel_nd.clear();
          rel_pnd.clear();
          rel_cid.clear();
          rel_pid.clear();
          tx.success();
        }
  finally {
          tx.finish();
        }
      }
      path1.clear();
    }
    tx=graphDb.beginTx();
    try {
      for (int i=0; i < rel_nd.size(); i++) {
        Relationship rel=rel_nd.get(i).createRelationshipTo(rel_pnd.get(i),RelTypes.TAXCHILDOF);
        rel.setProperty("String_Node_Str",filename);
        rel.setProperty("String_Node_Str",rel_cid.get(i));
        rel.setProperty("String_Node_Str",rel_pid.get(i));
      }
      rel_nd.clear();
      rel_pnd.clear();
      rel_cid.clear();
      rel_pid.clear();
      tx.success();
    }
  finally {
      tx.finish();
    }
    br.close();
  }
 catch (  IOException ioe) {
  }
}