Program: 89744
Project: 89744
Buggy source:
/** 
 * The method for voting about the checksum of a file. <br/> Each entry in the replicafileinfo table containing the file is retrieved. All the unique checksums are retrieved, e.g. if a checksum is found more than one, then it is ignored. <br/> If only one unique checksum is found, then if must be the correct one,  and all the replicas with this file will have their checksum_status set  to 'OK'. <br/> If more than one checksum is found, then a vote for the correct checksum is performed. This is done by counting the amount of time each of the  unique checksum is found among the replicafileinfo entries for the  current file. The checksum with most votes is chosen as the correct one, and the checksum_status for all the replicafileinfo entries with this  checksum is set to 'OK', whereas the replicafileinfo entries with a  different checksum is set to 'CORRUPT'. <br/>   If no winner is found then a warning and a notification is issued, and  the checksum_status for all the replicafileinfo entries with for the  current file is set to 'UNKNOWN'. <br/>
 * @param fileId The id for the file to vote about.
 */
private void fileChecksumVote(long fileId){
  List<Long> rfiGuids=retrieveReplicaFileInfoGuidsForFile(fileId);
  List<ReplicaFileInfo> rfis=retrieveReplicaFileInfosWithChecksum(rfiGuids);
  if (rfis.size() == 0) {
    log.warn("String_Node_Str" + retrieveFilenameForFileId(fileId) + "String_Node_Str");
    return;
  }
  Set<String> hs=new HashSet<String>(rfis.size());
  for (  ReplicaFileInfo rfi : rfis) {
    hs.add(rfi.getChecksum());
  }
  if (hs.size() <= 1) {
    log.trace("String_Node_Str" + fileId + "String_Node_Str");
    for (    ReplicaFileInfo rfi : rfis) {
      updateReplicaFileInfoChecksumOk(rfi.getGuid());
    }
    return;
  }
  int[] csCount=new int[hs.size()];
  String[] uniqueCs=hs.toArray(new String[hs.size()]);
  for (  ReplicaFileInfo rfi : rfis) {
    for (int i=0; i < hs.size(); i++) {
      if (rfi.getChecksum().equals(uniqueCs[i])) {
        csCount[i]++;
      }
    }
  }
  int largest=0;
  boolean unique=false;
  int index=-1;
  for (int i=0; i < csCount.length; i++) {
    if (csCount[i] > largest) {
      largest=csCount[i];
      unique=true;
      index=i;
    }
 else     if (csCount[i] == largest) {
      unique=false;
    }
  }
  if (unique) {
    for (    ReplicaFileInfo rfi : rfis) {
      if (!rfi.getChecksum().equals(uniqueCs[index])) {
        updateReplicaFileInfoChecksumCorrupt(rfi.getGuid());
      }
 else {
        updateReplicaFileInfoChecksumOk(rfi.getGuid());
      }
    }
  }
 else {
    String errMsg="String_Node_Str" + "String_Node_Str" + retrieveFilenameForFileId(fileId) + "String_Node_Str";
    log.error(errMsg);
    NotificationsFactory.getInstance().errorEvent(errMsg);
    for (    ReplicaFileInfo rfi : rfis) {
      updateReplicaFileInfoChecksumUnknown(rfi.getGuid());
    }
  }
}

Fixed version (ground truth):
/** 
 * The method for voting about the checksum of a file. <br/> Each entry in the replicafileinfo table containing the file is retrieved. All the unique checksums are retrieved, e.g. if a checksum is found more than one, then it is ignored. <br/> If only one unique checksum is found, then if must be the correct one,  and all the replicas with this file will have their checksum_status set  to 'OK'. <br/> If more than one checksum is found, then a vote for the correct checksum is performed. This is done by counting the amount of time each of the  unique checksum is found among the replicafileinfo entries for the  current file. The checksum with most votes is chosen as the correct one, and the checksum_status for all the replicafileinfo entries with this  checksum is set to 'OK', whereas the replicafileinfo entries with a  different checksum is set to 'CORRUPT'. <br/>   If no winner is found then a warning and a notification is issued, and  the checksum_status for all the replicafileinfo entries with for the  current file is set to 'UNKNOWN'. <br/>
 * @param fileId The id for the file to vote about.
 */
private void fileChecksumVote(long fileId){
  List<Long> rfiGuids=retrieveReplicaFileInfoGuidsForFile(fileId);
  List<ReplicaFileInfo> rfis=retrieveReplicaFileInfosWithChecksum(rfiGuids);
  if (rfis.size() == 0) {
    log.warn("String_Node_Str" + retrieveFilenameForFileId(fileId) + "String_Node_Str");
    return;
  }
  Set<String> hs=new HashSet<String>(rfis.size());
  for (  ReplicaFileInfo rfi : rfis) {
    if (rfi.getFileListState() == FileListStatus.OK) {
      hs.add(rfi.getChecksum());
    }
  }
  if (hs.size() == 0) {
    String errMsg="String_Node_Str" + fileId + "String_Node_Str";
    log.warn(errMsg);
    NotificationsFactory.getInstance().errorEvent(errMsg);
    return;
  }
  if (hs.size() == 1) {
    log.trace("String_Node_Str" + fileId + "String_Node_Str");
    for (    ReplicaFileInfo rfi : rfis) {
      updateReplicaFileInfoChecksumOk(rfi.getGuid());
    }
    return;
  }
  int[] csCount=new int[hs.size()];
  String[] uniqueCs=hs.toArray(new String[hs.size()]);
  for (  ReplicaFileInfo rfi : rfis) {
    if (rfi.getFileListState() == FileListStatus.OK) {
      for (int i=0; i < hs.size(); i++) {
        if (rfi.getChecksum().equals(uniqueCs[i])) {
          csCount[i]++;
        }
      }
    }
  }
  int largest=0;
  boolean unique=false;
  int index=-1;
  for (int i=0; i < csCount.length; i++) {
    if (csCount[i] > largest) {
      largest=csCount[i];
      unique=true;
      index=i;
    }
 else     if (csCount[i] == largest) {
      unique=false;
    }
  }
  if (unique) {
    for (    ReplicaFileInfo rfi : rfis) {
      if (!rfi.getChecksum().equals(uniqueCs[index])) {
        updateReplicaFileInfoChecksumCorrupt(rfi.getGuid());
      }
 else {
        updateReplicaFileInfoChecksumOk(rfi.getGuid());
      }
    }
  }
 else {
    String errMsg="String_Node_Str" + "String_Node_Str" + retrieveFilenameForFileId(fileId) + "String_Node_Str";
    log.error(errMsg);
    NotificationsFactory.getInstance().errorEvent(errMsg);
    for (    ReplicaFileInfo rfi : rfis) {
      updateReplicaFileInfoChecksumUnknown(rfi.getGuid());
    }
  }
}