Program: 140865
Project: 140865
Buggy source:
/** 
 * Converts the encoded queries in a given logfile to queries
 * @param pw the Printwriter to use to write the queries
 * @param input the logfile
 */
public static void logToQueries(PrintWriter pw,File input,Boolean onlyComplexQueries,Map<String,Long> map){
  FileInputStream fis=null;
  BufferedReader br=null;
  String line;
  try {
    fis=new FileInputStream(input);
    br=new BufferedReader(new InputStreamReader(fis,Charset.forName("String_Node_Str")));
    while ((line=br.readLine()) != null) {
      int index=line.indexOf("String_Node_Str");
      int lastIndex=line.indexOf("String_Node_Str",index + 1);
      line=line.substring(index,lastIndex);
      String graph=null;
      Pattern p=Pattern.compile("String_Node_Str");
      Matcher m=p.matcher(line);
      if (m.find()) {
        String complete=m.group();
        graph=complete.substring(complete.indexOf("String_Node_Str") + 1,complete.lastIndexOf("String_Node_Str"));
        graph=URLDecoder.decode(graph,"String_Node_Str");
      }
      line=line.replaceFirst("String_Node_Str","String_Node_Str");
      if ((index=line.indexOf("String_Node_Str")) >= 0)       line=line.substring(0,index);
      try {
        line=URLDecoder.decode(line,"String_Node_Str");
      }
 catch (      Exception e) {
        log.warning("String_Node_Str" + line);
        LogHandler.writeStackTrace(log,e,Level.WARNING);
      }
      line=line.replaceAll("String_Node_Str","String_Node_Str");
      line=queryVarRename(line);
      Query q=QuerySorter.isSPARQL(line);
      try {
        if (q == null && !QuerySorter.isSPARQLUpdate(line)) {
          throw new QueryException();
        }
        Byte[] features=LogSolution.getFeatureVector(line,LogSolution.getFeatures());
        int count=LogSolution.countTriplesInQuery(line);
        String feat2="String_Node_Str";
        for (int i=0; i < features.length - 1; i++) {
          feat2+=features[i] + "String_Node_Str";
        }
        feat2+=features[features.length - 1];
        Long n=map.get(feat2 + "String_Node_Str" + count);
        if (n == null)         n=0L;
        map.put(features + "String_Node_Str" + count,n + 1);
        if (q != null) {
          if (graph != null) {
            q.addGraphURI(graph);
          }
          line=q.toString().replace("String_Node_Str","String_Node_Str");
        }
        if (onlyComplexQueries) {
          if (countTriplesInQuery(line) <= 1) {
            continue;
          }
          Boolean cont=false;
          for (          String feat : getFeatures()) {
            if (line.contains(feat)) {
              cont=true;
              break;
            }
          }
          if (!cont)           continue;
        }
        pw.println(line.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str"));
      }
 catch (      QueryException e) {
      }
    }
    pw.flush();
  }
 catch (  IOException e) {
    LogHandler.writeStackTrace(log,e,Level.SEVERE);
  }
 finally {
    try {
      fis.close();
      br.close();
    }
 catch (    IOException e) {
      LogHandler.writeStackTrace(log,e,Level.SEVERE);
    }
  }
}

Fixed version (ground truth):
/** 
 * Converts the encoded queries in a given logfile to queries
 * @param pw the Printwriter to use to write the queries
 * @param input the logfile
 */
public static void logToQueries(PrintWriter pw,File input,Boolean onlyComplexQueries,Map<String,Long> map){
  FileInputStream fis=null;
  BufferedReader br=null;
  String line;
  try {
    fis=new FileInputStream(input);
    br=new BufferedReader(new InputStreamReader(fis,Charset.forName("String_Node_Str")));
    while ((line=br.readLine()) != null) {
      int index=line.indexOf("String_Node_Str");
      int lastIndex=line.indexOf("String_Node_Str",index + 1);
      String line2=line.substring(index,lastIndex);
      String graph=null;
      Pattern p=Pattern.compile("String_Node_Str");
      Matcher m=p.matcher(line2);
      if (m.find()) {
        String complete=m.group();
        graph=complete.substring(complete.indexOf("String_Node_Str") + 1,complete.lastIndexOf("String_Node_Str"));
        graph=URLDecoder.decode(graph,"String_Node_Str");
      }
      List<String> tokens=Arrays.asList(line.split("String_Node_Str"));
      String prequery="String_Node_Str";
      for (int j=0; j < tokens.size(); j++) {
        if (tokens.get(j).contains("String_Node_Str")) {
          prequery=tokens.get(j).replaceFirst("String_Node_Str","String_Node_Str");
        }
      }
      line=prequery.replaceAll("String_Node_Str","String_Node_Str");
      if ((index=line.indexOf("String_Node_Str")) >= 0)       line=line.substring(0,index);
      try {
        line=URLDecoder.decode(line,"String_Node_Str");
      }
 catch (      Exception e) {
        log.warning("String_Node_Str" + line);
        LogHandler.writeStackTrace(log,e,Level.WARNING);
      }
      line=line.replaceAll("String_Node_Str","String_Node_Str");
      line=queryVarRename(line);
      Query q=QuerySorter.isSPARQL(line);
      try {
        if (q == null && !QuerySorter.isSPARQLUpdate(line)) {
          throw new QueryException();
        }
        Byte[] features=LogSolution.getFeatureVector(line,LogSolution.getFeatures());
        int count=LogSolution.countTriplesInQuery(line);
        String feat2="String_Node_Str";
        for (int i=0; i < features.length - 1; i++) {
          feat2+=features[i] + "String_Node_Str";
        }
        feat2+=features[features.length - 1];
        Long n=map.get(feat2 + "String_Node_Str" + count);
        if (n == null)         n=0L;
        map.put(features + "String_Node_Str" + count,n + 1);
        if (q != null) {
          if (graph != null) {
            q.addGraphURI(graph);
          }
          line=q.toString().replace("String_Node_Str","String_Node_Str");
        }
        if (onlyComplexQueries) {
          if (countTriplesInQuery(line) <= 1) {
            continue;
          }
          Boolean cont=false;
          for (          String feat : getFeatures()) {
            if (line.contains(feat)) {
              cont=true;
              break;
            }
          }
          if (!cont)           continue;
        }
        pw.println(line.replace("String_Node_Str","String_Node_Str").replace("String_Node_Str","String_Node_Str").replaceAll("String_Node_Str","String_Node_Str"));
      }
 catch (      QueryException e) {
      }
    }
    pw.flush();
  }
 catch (  IOException e) {
    LogHandler.writeStackTrace(log,e,Level.SEVERE);
  }
 finally {
    try {
      fis.close();
      br.close();
    }
 catch (    IOException e) {
      LogHandler.writeStackTrace(log,e,Level.SEVERE);
    }
  }
}