Program: 9518
Project: 9518
Buggy source:
public ArrayList<Template> createTemplates(String question) throws IOException {
  long start=System.currentTimeMillis();
  ArrayList<Template> resultArrayList=new ArrayList<Template>();
  Set<BasicQueryTemplate> querytemps=null;
  querytemps=btemplator.buildBasicQueries(question);
  if (querytemps.contains("String_Node_Str") || querytemps.isEmpty()) {
    String dateiname="String_Node_Str";
    String result_string="String_Node_Str";
    try {
      BufferedReader br=new BufferedReader(new FileReader(dateiname));
      String thisLine;
      while ((thisLine=br.readLine()) != null) {
        result_string+=thisLine + "String_Node_Str";
      }
    }
 catch (    IOException e) {
      System.err.println("String_Node_Str" + e);
    }
    File file=new File(dateiname);
    BufferedWriter bw=new BufferedWriter(new FileWriter(file));
    bw.write(result_string + "String_Node_Str" + question);
    bw.flush();
    bw.close();
  }
  long stop_template=System.currentTimeMillis();
  for (  BasicQueryTemplate bqt : querytemps) {
    long start_part1=System.currentTimeMillis();
    ArrayList<ArrayList<String>> condition=new ArrayList<ArrayList<String>>();
    String selectTerm="String_Node_Str";
    String having="String_Node_Str";
    String filter="String_Node_Str";
    String OrderBy="String_Node_Str";
    String limit="String_Node_Str";
    boolean addTemplate=true;
    try {
      for (      SPARQL_Term terms : bqt.getSelTerms())       selectTerm=selectTerm + (terms.toString()) + "String_Node_Str";
    }
 catch (    Exception e) {
      selectTerm="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      Path conditions1 : bqt.getConditions()) {
        ArrayList<String> temp_array=new ArrayList<String>();
        String[] tmp_array=conditions1.toString().split("String_Node_Str");
        for (        String s : tmp_array) {
          temp_array.add(s);
        }
        condition.add(temp_array);
      }
    }
 catch (    Exception e) {
      addTemplate=false;
    }
    try {
      for (      SPARQL_Filter tmp : bqt.getFilters())       filter=filter + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      filter="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      SPARQL_Having tmp : bqt.getHavings())       having=having + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      having="String_Node_Str";
      addTemplate=false;
    }
    OrderBy="String_Node_Str";
    try {
      for (      SPARQL_Term tmp : bqt.getOrderBy()) {
        OrderBy=OrderBy + tmp + "String_Node_Str";
      }
      if ((bqt.getOrderBy()).size() == 0)       OrderBy="String_Node_Str";
    }
 catch (    Exception e) {
      OrderBy="String_Node_Str";
      addTemplate=false;
    }
    try {
      limit="String_Node_Str" + bqt.getLimit();
      if (bqt.getLimit() == 0)       limit="String_Node_Str";
    }
 catch (    Exception e) {
      limit="String_Node_Str";
      addTemplate=false;
    }
    long stop_part1=System.currentTimeMillis();
    if (addTemplate != false) {
      long start_part2=System.currentTimeMillis();
      Template template=new Template(condition,bqt.getQt().toString(),having,filter,selectTerm,OrderBy,limit,question);
      template.setTime_part1(stop_part1 - start_part1);
      boolean add_reverse_template=true;
      ArrayList<Hypothesis> list_of_hypothesis=new ArrayList<Hypothesis>();
      for (      Slot slot : bqt.getSlots()) {
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          boolean no_iaA_found=true;
          for (          ArrayList<String> x : condition) {
            if (x.get(1).equals("String_Node_Str") && x.get(2).equals("String_Node_Str" + tmp_array[0])) {
              no_iaA_found=false;
              Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
              list_of_hypothesis.add(tmp_hypothesis);
              add_reverse_template=false;
            }
          }
          if (no_iaA_found) {
            Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
            list_of_hypothesis.add(tmp_hypothesis);
          }
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
      }
      ArrayList<ArrayList<Hypothesis>> final_list_set_hypothesis=new ArrayList<ArrayList<Hypothesis>>();
      for (      Hypothesis x : list_of_hypothesis) {
        if (x.getType().contains("String_Node_Str") || x.getType().contains("String_Node_Str") || x.getType().contains("String_Node_Str")) {
          ArrayList<String> result=new ArrayList<String>();
          try {
            if (x.getType().contains("String_Node_Str")) {
              result=Index_utils.searchIndexForClass(x.getUri(),myindex);
            }
 else {
              result=Index_utils.searchIndexForResource(x.getUri(),myindex);
            }
          }
 catch (          SQLException e) {
            e.printStackTrace();
          }
          for (          String s : result) {
            ArrayList<Hypothesis> new_list=new ArrayList<Hypothesis>();
            for (            Hypothesis h : list_of_hypothesis) {
              if (h.getUri().equals(x.getUri())) {
                if (s != null) {
                  Hypothesis new_h=new Hypothesis(h.getVariable(),h.getName(),s,h.getType(),1.0);
                  new_list.add(new_h);
                }
 else {
                  Hypothesis new_h=new Hypothesis(h.getVariable(),h.getName(),h.getUri(),h.getType(),1.0);
                  new_list.add(new_h);
                }
              }
 else {
                Hypothesis new_h=new Hypothesis(h.getVariable(),h.getName(),h.getUri(),h.getType(),h.getRank());
                new_list.add(new_h);
              }
            }
            final_list_set_hypothesis.add(new_list);
          }
        }
      }
      HashMap<String,String> hm=new HashMap<String,String>();
      for (      ArrayList<Hypothesis> x : final_list_set_hypothesis) {
        for (        Hypothesis h : x) {
          if (h.getType().contains("String_Node_Str")) {
            ArrayList<String> result=new ArrayList<String>();
            try {
              if (hm.containsKey(h.getUri().toLowerCase())) {
                result.add(hm.get(h.getUri().toLowerCase()));
              }
 else {
                result=Index_utils.searchIndexForProperty(h.getUri(),myindex);
                if (!result.isEmpty())                 hm.put(h.getUri().toLowerCase(),result.get(0));
              }
              if (!result.isEmpty()) {
                h.setUri(result.get(0));
                h.setRank(0.0);
              }
            }
 catch (            SQLException e) {
              e.printStackTrace();
            }
          }
        }
      }
      template.setHypothesen(final_list_set_hypothesis);
      Template template_reverse_conditions=new Template(template.getCondition(),template.getQueryType(),template.getHaving(),template.getFilter(),template.getSelectTerm(),template.getOrderBy(),template.getLimit(),template.getQuestion());
      ArrayList<ArrayList<String>> condition_template_reverse_conditions=template_reverse_conditions.getCondition();
      ArrayList<ArrayList<String>> condition_reverse_new=new ArrayList<ArrayList<String>>();
      if (add_reverse_template) {
        for (        ArrayList<String> x : condition_template_reverse_conditions) {
          ArrayList<String> new_list=new ArrayList<String>();
          new_list.add(x.get(2));
          new_list.add(x.get(1));
          new_list.add(x.get(0));
          condition_reverse_new.add(new_list);
        }
      }
      long stop=System.currentTimeMillis();
      template_reverse_conditions.setOverallTime(stop - start);
      template.setOverallTime(stop - start);
      template_reverse_conditions.setTime_Templator(stop_template - start);
      template.setTime_Templator(stop_template - start);
      template_reverse_conditions.setCondition(condition_reverse_new);
      template_reverse_conditions.setHypothesen(template.getHypothesen());
      long start_elements=System.currentTimeMillis();
      Elements elm=new Elements(template.getCondition(),template.getHypothesen());
      long stop_elements=System.currentTimeMillis();
      template.setTime_generateElements(stop_elements - start_elements);
      long stop_part2=System.currentTimeMillis();
      template.setTime_part2(stop_part2 - start_part2);
      if (elm.isElementEmty() == false) {
        template.setElm(elm);
        resultArrayList.add(template);
      }
      if (add_reverse_template) {
        start_elements=System.currentTimeMillis();
        Elements elm_reverse=new Elements(template_reverse_conditions.getCondition(),template_reverse_conditions.getHypothesen());
        stop_elements=System.currentTimeMillis();
        template_reverse_conditions.setTime_generateElements(stop_elements - start_elements);
        template_reverse_conditions.setTime_part1(stop_part1 - start_part1);
        template_reverse_conditions.setTime_part2(stop_part2 - start_part2);
        if (elm_reverse.isElementEmty() == false) {
          template_reverse_conditions.setElm(elm_reverse);
          resultArrayList.add(template_reverse_conditions);
        }
      }
    }
  }
  return resultArrayList;
}

Fixed version (ground truth):
public ArrayList<Template> createTemplates(String question) throws IOException {
  long start=System.currentTimeMillis();
  ArrayList<Template> resultArrayList=new ArrayList<Template>();
  Set<BasicQueryTemplate> querytemps=null;
  querytemps=btemplator.buildBasicQueries(question);
  if (querytemps.contains("String_Node_Str") || querytemps.isEmpty()) {
    String dateiname="String_Node_Str";
    String result_string="String_Node_Str";
    try {
      BufferedReader br=new BufferedReader(new FileReader(dateiname));
      String thisLine;
      while ((thisLine=br.readLine()) != null) {
        result_string+=thisLine + "String_Node_Str";
      }
    }
 catch (    IOException e) {
      System.err.println("String_Node_Str" + e);
    }
    File file=new File(dateiname);
    BufferedWriter bw=new BufferedWriter(new FileWriter(file));
    bw.write(result_string + "String_Node_Str" + question);
    bw.flush();
    bw.close();
  }
  long stop_template=System.currentTimeMillis();
  for (  BasicQueryTemplate bqt : querytemps) {
    long start_part1=System.currentTimeMillis();
    ArrayList<ArrayList<String>> condition=new ArrayList<ArrayList<String>>();
    String selectTerm="String_Node_Str";
    String having="String_Node_Str";
    String filter="String_Node_Str";
    String OrderBy="String_Node_Str";
    String limit="String_Node_Str";
    boolean addTemplate=true;
    try {
      for (      SPARQL_Term terms : bqt.getSelTerms())       selectTerm=selectTerm + (terms.toString()) + "String_Node_Str";
    }
 catch (    Exception e) {
      selectTerm="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      Path conditions1 : bqt.getConditions()) {
        ArrayList<String> temp_array=new ArrayList<String>();
        String[] tmp_array=conditions1.toString().split("String_Node_Str");
        for (        String s : tmp_array) {
          s=s.replace("String_Node_Str","String_Node_Str");
          temp_array.add(s);
        }
        condition.add(temp_array);
      }
    }
 catch (    Exception e) {
      addTemplate=false;
    }
    try {
      for (      SPARQL_Filter tmp : bqt.getFilters())       filter=filter + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      filter="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      SPARQL_Having tmp : bqt.getHavings())       having=having + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      having="String_Node_Str";
      addTemplate=false;
    }
    OrderBy="String_Node_Str";
    try {
      for (      SPARQL_Term tmp : bqt.getOrderBy()) {
        OrderBy=OrderBy + tmp + "String_Node_Str";
      }
      if ((bqt.getOrderBy()).size() == 0)       OrderBy="String_Node_Str";
    }
 catch (    Exception e) {
      OrderBy="String_Node_Str";
      addTemplate=false;
    }
    try {
      limit="String_Node_Str" + bqt.getLimit();
      if (bqt.getLimit() == 0)       limit="String_Node_Str";
    }
 catch (    Exception e) {
      limit="String_Node_Str";
      addTemplate=false;
    }
    long stop_part1=System.currentTimeMillis();
    if (addTemplate != false) {
      long start_part2=System.currentTimeMillis();
      Template template=new Template(condition,bqt.getQt().toString(),having,filter,selectTerm,OrderBy,limit,question);
      for (      ArrayList<String> al : condition) {
        String con_temp="String_Node_Str";
        for (        String s : al) {
          con_temp+="String_Node_Str" + s;
        }
        System.out.println("String_Node_Str" + con_temp);
      }
      template.setTime_part1(stop_part1 - start_part1);
      boolean add_reverse_template=true;
      ArrayList<Hypothesis> list_of_hypothesis=new ArrayList<Hypothesis>();
      for (      Slot slot : bqt.getSlots()) {
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          boolean no_iaA_found=true;
          for (          ArrayList<String> x : condition) {
            if (x.get(1).equals("String_Node_Str") && x.get(2).equals("String_Node_Str" + tmp_array[0])) {
              no_iaA_found=false;
              Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
              list_of_hypothesis.add(tmp_hypothesis);
              add_reverse_template=false;
            }
          }
          if (no_iaA_found) {
            Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
            list_of_hypothesis.add(tmp_hypothesis);
          }
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],tmp_array[1],"String_Node_Str",0.0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
      }
      ArrayList<ArrayList<Hypothesis>> final_list_set_hypothesis=new ArrayList<ArrayList<Hypothesis>>();
      System.out.println("String_Node_Str");
      for (      Hypothesis x : list_of_hypothesis) {
        x.printAll();
      }
      System.out.println("String_Node_Str");
      for (      Hypothesis x : list_of_hypothesis) {
        if (x.getType().contains("String_Node_Str") || x.getType().contains("String_Node_Str") || x.getType().contains("String_Node_Str")) {
          ArrayList<String> result=new ArrayList<String>();
          try {
            if (x.getType().contains("String_Node_Str")) {
              result=Index_utils.searchIndexForClass(x.getUri(),myindex);
            }
 else {
              result=Index_utils.searchIndexForResource(x.getUri(),myindex);
            }
          }
 catch (          SQLException e) {
            e.printStackTrace();
          }
          for (          String s : result) {
            ArrayList<Hypothesis> new_list=new ArrayList<Hypothesis>();
            for (            Hypothesis h : list_of_hypothesis) {
              if (h.getUri().equals(x.getUri())) {
                if (s != null) {
                  Hypothesis new_h=new Hypothesis(h.getVariable(),h.getName(),s,h.getType(),1.0);
                  new_list.add(new_h);
                }
 else {
                  Hypothesis new_h=new Hypothesis(h.getVariable(),h.getName(),h.getUri(),h.getType(),1.0);
                  new_list.add(new_h);
                }
              }
 else {
                Hypothesis new_h=new Hypothesis(h.getVariable(),h.getName(),h.getUri(),h.getType(),h.getRank());
                new_list.add(new_h);
              }
            }
            final_list_set_hypothesis.add(new_list);
          }
        }
      }
      System.out.println("String_Node_Str");
      for (      ArrayList<Hypothesis> lh : final_list_set_hypothesis) {
        for (        Hypothesis x : lh) {
          x.printAll();
        }
      }
      System.out.println("String_Node_Str");
      HashMap<String,String> hm=new HashMap<String,String>();
      for (      ArrayList<Hypothesis> x : final_list_set_hypothesis) {
        for (        Hypothesis h : x) {
          if (h.getType().contains("String_Node_Str")) {
            ArrayList<String> result=new ArrayList<String>();
            try {
              if (hm.containsKey(h.getUri().toLowerCase())) {
                result.add(hm.get(h.getUri().toLowerCase()));
              }
 else {
                result=Index_utils.searchIndexForProperty(h.getUri(),myindex);
                if (!result.isEmpty())                 hm.put(h.getUri().toLowerCase(),result.get(0));
              }
              if (!result.isEmpty()) {
                h.setUri(result.get(0));
                h.setRank(0.0);
              }
            }
 catch (            SQLException e) {
              e.printStackTrace();
            }
          }
        }
      }
      System.out.println("String_Node_Str");
      for (      ArrayList<Hypothesis> lh : final_list_set_hypothesis) {
        for (        Hypothesis x : lh) {
          x.printAll();
        }
      }
      System.out.println("String_Node_Str");
      template.setHypothesen(final_list_set_hypothesis);
      Template template_reverse_conditions=new Template(template.getCondition(),template.getQueryType(),template.getHaving(),template.getFilter(),template.getSelectTerm(),template.getOrderBy(),template.getLimit(),template.getQuestion());
      ArrayList<ArrayList<String>> condition_template_reverse_conditions=template_reverse_conditions.getCondition();
      ArrayList<ArrayList<String>> condition_reverse_new=new ArrayList<ArrayList<String>>();
      if (add_reverse_template) {
        for (        ArrayList<String> x : condition_template_reverse_conditions) {
          ArrayList<String> new_list=new ArrayList<String>();
          new_list.add(x.get(2));
          new_list.add(x.get(1));
          new_list.add(x.get(0));
          condition_reverse_new.add(new_list);
        }
      }
      long stop=System.currentTimeMillis();
      template_reverse_conditions.setOverallTime(stop - start);
      template.setOverallTime(stop - start);
      template_reverse_conditions.setTime_Templator(stop_template - start);
      template.setTime_Templator(stop_template - start);
      template_reverse_conditions.setCondition(condition_reverse_new);
      template_reverse_conditions.setHypothesen(template.getHypothesen());
      long start_elements=System.currentTimeMillis();
      Elements elm=new Elements(template.getCondition(),template.getHypothesen());
      long stop_elements=System.currentTimeMillis();
      template.setTime_generateElements(stop_elements - start_elements);
      long stop_part2=System.currentTimeMillis();
      template.setTime_part2(stop_part2 - start_part2);
      if (elm.isElementEmty() == false) {
        template.setElm(elm);
        resultArrayList.add(template);
      }
      if (add_reverse_template) {
        start_elements=System.currentTimeMillis();
        Elements elm_reverse=new Elements(template_reverse_conditions.getCondition(),template_reverse_conditions.getHypothesen());
        stop_elements=System.currentTimeMillis();
        template_reverse_conditions.setTime_generateElements(stop_elements - start_elements);
        template_reverse_conditions.setTime_part1(stop_part1 - start_part1);
        template_reverse_conditions.setTime_part2(stop_part2 - start_part2);
        if (elm_reverse.isElementEmty() == false) {
          template_reverse_conditions.setElm(elm_reverse);
          resultArrayList.add(template_reverse_conditions);
        }
      }
    }
  }
  return resultArrayList;
}