Program: 4608
Project: 4608
Buggy source:
/** 
 * Checks whether the existing run record metas of a given program run are in a state for the program run to transition into the given run status.
 * @param existingRecords the existing run record metas of the given program run
 * @param programId id of the program
 * @param pid run id
 * @param sourceId the source id of the current program status
 * @param recordType the type of record corresponding to the current status
 * @param status the status that the program run is transitioning into
 * @return {@code true} if the program run is allowed to persist the given status, {@code false} otherwise
 */
private boolean validateExistingRecords(List<RunRecordMeta> existingRecords,ProgramId programId,String pid,byte[] sourceId,String recordType,ProgramRunStatus status){
  if (existingRecords.size() > 1) {
    LOG.warn("String_Node_Str" + "String_Node_Str",existingRecords,programId,pid,recordType);
    return false;
  }
  Set<ProgramRunStatus> allowedStatuses=ALLOWED_STATUSES.get(status);
  Set<ProgramRunStatus> allowedWithLogStatuses=ALLOWED_WITH_LOG_STATUSES.get(status);
  if (allowedStatuses == null || allowedWithLogStatuses == null) {
    LOG.error("String_Node_Str",status,programId,pid);
    return false;
  }
  if (allowedStatuses.isEmpty() && allowedWithLogStatuses.isEmpty()) {
    if (existingRecords.isEmpty()) {
      return true;
    }
    LOG.error("String_Node_Str",programId,pid,existingRecords);
    return false;
  }
  if (existingRecords.isEmpty()) {
    LOG.error("String_Node_Str",programId,pid,recordType);
    return false;
  }
  RunRecordMeta existing=existingRecords.get(0);
  byte[] existingSourceId=existing.getSourceId();
  if (existingSourceId != null && Bytes.compareTo(sourceId,existingSourceId) <= 0) {
    LOG.debug("String_Node_Str" + "String_Node_Str",Bytes.toHexString(sourceId),Bytes.toHexString(existingSourceId),existingRecords.get(0),recordType,programId,pid);
    return false;
  }
  ProgramRunStatus existingStatus=existing.getStatus();
  if (allowedStatuses.contains(existingStatus)) {
    return true;
  }
  if (allowedWithLogStatuses.contains(existingStatus)) {
    LOG.debug("String_Node_Str",existing,programId,pid,recordType);
    return true;
  }
  LOG.warn("String_Node_Str" + "String_Node_Str",existing,programId,pid,existingStatus,recordType);
  return false;
}

Fixed version (ground truth):
/** 
 * Checks whether the existing run record metas of a given program run are in a state for the program run to transition into the given run status.
 * @param existing the existing run record meta of the given program run
 * @param programId id of the program
 * @param pid run id
 * @param sourceId the source id of the current program status
 * @param recordType the type of record corresponding to the current status
 * @param status the status that the program run is transitioning into
 * @return {@code true} if the program run is allowed to persist the given status, {@code false} otherwise
 */
private boolean validateExistingRecords(RunRecordMeta existing,ProgramId programId,String pid,byte[] sourceId,String recordType,ProgramRunStatus status){
  Set<ProgramRunStatus> allowedStatuses=ALLOWED_STATUSES.get(status);
  Set<ProgramRunStatus> allowedWithLogStatuses=ALLOWED_WITH_LOG_STATUSES.get(status);
  if (allowedStatuses == null || allowedWithLogStatuses == null) {
    LOG.error("String_Node_Str",status,programId,pid);
    return false;
  }
  if (allowedStatuses.isEmpty() && allowedWithLogStatuses.isEmpty()) {
    if (existing == null) {
      return true;
    }
    LOG.error("String_Node_Str",programId,pid,existing);
    return false;
  }
  if (existing == null) {
    LOG.error("String_Node_Str",programId,pid,recordType);
    return false;
  }
  byte[] existingSourceId=existing.getSourceId();
  if (existingSourceId != null && Bytes.compareTo(sourceId,existingSourceId) <= 0) {
    LOG.debug("String_Node_Str" + "String_Node_Str",Bytes.toHexString(sourceId),Bytes.toHexString(existingSourceId),existing,recordType,programId,pid);
    return false;
  }
  ProgramRunStatus existingStatus=existing.getStatus();
  if (allowedStatuses.contains(existingStatus)) {
    return true;
  }
  if (allowedWithLogStatuses.contains(existingStatus)) {
    LOG.debug("String_Node_Str",existing,programId,pid,recordType);
    return true;
  }
  LOG.warn("String_Node_Str" + "String_Node_Str",existing,programId,pid,existingStatus,recordType);
  return false;
}