Program: 3512
Project: 3512
Buggy source:
/** 
 * using the pre-configuration information passed here, analyse the logs and produce the aggregation file
 * @param context     the DSpace context object this occurs under
 * @param myLogDir    the passed log directory.  Uses default if null
 * @param myFileTemplate  the passed file name regex.  Uses default if null
 * @param myConfigFile    the DStat config file.  Uses default if null
 * @param myOutFile    the file to which to output aggregation data.  Uses default if null
 * @param myStartDate     the desired start of the analysis.  Starts from the beginning otherwise
 * @param myEndDate       the desired end of the analysis.  Goes to the end otherwise
 * @param myLookUp        force a lookup of the database
 */
public static void processLogs(Context context,String myLogDir,String myFileTemplate,String myConfigFile,String myOutFile,Date myStartDate,Date myEndDate,boolean myLookUp) throws IOException, SQLException {
  startTime=new GregorianCalendar();
  actionAggregator=new HashMap();
  searchAggregator=new HashMap();
  userAggregator=new HashMap();
  itemAggregator=new HashMap();
  archiveStats=new HashMap();
  generalSummary=new ArrayList();
  excludeWords=new ArrayList();
  excludeTypes=new ArrayList();
  excludeChars=new ArrayList();
  itemTypes=new ArrayList();
  setParameters(myLogDir,myFileTemplate,myConfigFile,myOutFile,myStartDate,myEndDate,myLookUp);
  FileReader fr=null;
  BufferedReader br=null;
  readConfig(configFile);
  setRegex(fileTemplate);
  File[] logFiles=getLogFiles(logDir);
  int i=0;
  for (i=0; i < logFiles.length; i++) {
    Matcher matchRegex=logRegex.matcher(logFiles[i].getName());
    if (matchRegex.matches()) {
      try {
        fr=new FileReader(logFiles[i].toString());
        br=new BufferedReader(fr);
      }
 catch (      IOException e) {
        System.out.println("String_Node_Str" + logFiles[i].toString());
        System.exit(0);
      }
      String line=null;
      while ((line=br.readLine()) != null) {
        LogLine logLine=getLogLine(line);
        if (logLine != null) {
          if (logLine.beforeDate(startDate)) {
            continue;
          }
          if (logLine.afterDate(endDate)) {
            break;
          }
          lineCount++;
          if (startDate == null) {
            if (logStartDate != null) {
              if (logLine.beforeDate(logStartDate)) {
                logStartDate=logLine.getDate();
              }
            }
 else {
              logStartDate=logLine.getDate();
            }
          }
          if (endDate == null) {
            if (logEndDate != null) {
              if (logLine.afterDate(logEndDate)) {
                logEndDate=logLine.getDate();
              }
            }
 else {
              logEndDate=logLine.getDate();
            }
          }
          if (logLine.isLevel("String_Node_Str")) {
            warnCount++;
          }
          if (logLine.isAction("String_Node_Str")) {
            String[] words=analyseQuery(logLine.getParams());
            for (int j=0; j < words.length; j++) {
              searchAggregator.put(words[j],increment(searchAggregator,words[j]));
            }
          }
          if (logLine.isAction("String_Node_Str") && !userEmail.equals("String_Node_Str")) {
            userAggregator.put(logLine.getUser(),increment(userAggregator,logLine.getUser()));
          }
          if (logLine.isAction("String_Node_Str")) {
            String handle=logLine.getParams();
            Matcher matchHandle=handleRX.matcher(handle);
            handle=matchHandle.replaceAll("String_Node_Str");
            Matcher matchItem=itemRX.matcher(handle);
            handle=matchItem.replaceAll("String_Node_Str");
            handle.trim();
            itemAggregator.put(handle,increment(itemAggregator,handle));
          }
          actionAggregator.put(logLine.getAction(),increment(actionAggregator,logLine.getAction()));
        }
      }
      br.close();
      fr.close();
    }
  }
  archiveStats.put("String_Node_Str",getNumItems(context));
  for (i=0; i < itemTypes.size(); i++) {
    archiveStats.put(itemTypes.get(i),getNumItems(context,(String)itemTypes.get(i)));
  }
  hostName=ConfigurationManager.getProperty("String_Node_Str").trim();
  name=ConfigurationManager.getProperty("String_Node_Str").trim();
  url=ConfigurationManager.getProperties("String_Node_Str").trim();
  if ((url != null) && (!url.endsWith("String_Node_Str"))) {
    url=url + "String_Node_Str";
  }
  if (((Integer)archiveStats.get("String_Node_Str")).intValue() != 0) {
    Double avg=new Double(Math.ceil(((Integer)actionAggregator.get("String_Node_Str")).intValue() / ((Integer)archiveStats.get("String_Node_Str")).intValue()));
    views=avg.intValue();
  }
  createOutput();
  return;
}

Fixed version (ground truth):
/** 
 * using the pre-configuration information passed here, analyse the logs and produce the aggregation file
 * @param context     the DSpace context object this occurs under
 * @param myLogDir    the passed log directory.  Uses default if null
 * @param myFileTemplate  the passed file name regex.  Uses default if null
 * @param myConfigFile    the DStat config file.  Uses default if null
 * @param myOutFile    the file to which to output aggregation data.  Uses default if null
 * @param myStartDate     the desired start of the analysis.  Starts from the beginning otherwise
 * @param myEndDate       the desired end of the analysis.  Goes to the end otherwise
 * @param myLookUp        force a lookup of the database
 */
public static void processLogs(Context context,String myLogDir,String myFileTemplate,String myConfigFile,String myOutFile,Date myStartDate,Date myEndDate,boolean myLookUp) throws IOException, SQLException {
  startTime=new GregorianCalendar();
  actionAggregator=new HashMap();
  searchAggregator=new HashMap();
  userAggregator=new HashMap();
  itemAggregator=new HashMap();
  archiveStats=new HashMap();
  generalSummary=new ArrayList();
  excludeWords=new ArrayList();
  excludeTypes=new ArrayList();
  excludeChars=new ArrayList();
  itemTypes=new ArrayList();
  setParameters(myLogDir,myFileTemplate,myConfigFile,myOutFile,myStartDate,myEndDate,myLookUp);
  FileReader fr=null;
  BufferedReader br=null;
  readConfig(configFile);
  setRegex(fileTemplate);
  File[] logFiles=getLogFiles(logDir);
  int i=0;
  for (i=0; i < logFiles.length; i++) {
    Matcher matchRegex=logRegex.matcher(logFiles[i].getName());
    if (matchRegex.matches()) {
      try {
        fr=new FileReader(logFiles[i].toString());
        br=new BufferedReader(fr);
      }
 catch (      IOException e) {
        System.out.println("String_Node_Str" + logFiles[i].toString());
        System.exit(0);
      }
      String line=null;
      while ((line=br.readLine()) != null) {
        LogLine logLine=getLogLine(line);
        if (logLine != null) {
          if (logLine.beforeDate(startDate)) {
            continue;
          }
          if (logLine.afterDate(endDate)) {
            break;
          }
          lineCount++;
          if (startDate == null) {
            if (logStartDate != null) {
              if (logLine.beforeDate(logStartDate)) {
                logStartDate=logLine.getDate();
              }
            }
 else {
              logStartDate=logLine.getDate();
            }
          }
          if (endDate == null) {
            if (logEndDate != null) {
              if (logLine.afterDate(logEndDate)) {
                logEndDate=logLine.getDate();
              }
            }
 else {
              logEndDate=logLine.getDate();
            }
          }
          if (logLine.isLevel("String_Node_Str")) {
            warnCount++;
          }
          if (logLine.isAction("String_Node_Str")) {
            String[] words=analyseQuery(logLine.getParams());
            for (int j=0; j < words.length; j++) {
              searchAggregator.put(words[j],increment(searchAggregator,words[j]));
            }
          }
          if (logLine.isAction("String_Node_Str") && !userEmail.equals("String_Node_Str")) {
            userAggregator.put(logLine.getUser(),increment(userAggregator,logLine.getUser()));
          }
          if (logLine.isAction("String_Node_Str")) {
            String handle=logLine.getParams();
            Matcher matchHandle=handleRX.matcher(handle);
            handle=matchHandle.replaceAll("String_Node_Str");
            Matcher matchItem=itemRX.matcher(handle);
            handle=matchItem.replaceAll("String_Node_Str");
            handle.trim();
            itemAggregator.put(handle,increment(itemAggregator,handle));
          }
          actionAggregator.put(logLine.getAction(),increment(actionAggregator,logLine.getAction()));
        }
      }
      br.close();
      fr.close();
    }
  }
  archiveStats.put("String_Node_Str",getNumItems(context));
  for (i=0; i < itemTypes.size(); i++) {
    archiveStats.put(itemTypes.get(i),getNumItems(context,(String)itemTypes.get(i)));
  }
  hostName=ConfigurationManager.getProperty("String_Node_Str").trim();
  name=ConfigurationManager.getProperty("String_Node_Str").trim();
  url=ConfigurationManager.getProperty("String_Node_Str").trim();
  if ((url != null) && (!url.endsWith("String_Node_Str"))) {
    url=url + "String_Node_Str";
  }
  if (((Integer)archiveStats.get("String_Node_Str")).intValue() != 0) {
    Double avg=new Double(Math.ceil(((Integer)actionAggregator.get("String_Node_Str")).intValue() / ((Integer)archiveStats.get("String_Node_Str")).intValue()));
    views=avg.intValue();
  }
  createOutput();
  return;
}