Program: 6165
Project: 6165
Buggy source:
/** 
 * Helper method to get   {@link ProgramId} for a RunRecord for type of program
 * @param programType Type of program to search
 * @param runId The target id of the {@link RunRecord} to find
 * @return the program id of the run record or {@code null} if does not exist.
 */
@Nullable private ProgramId retrieveProgramIdForRunRecord(ProgramType programType,String runId){
  List<NamespaceMeta> namespaceMetas=nsStore.list();
  ProgramId targetProgramId=null;
  for (  NamespaceMeta nm : namespaceMetas) {
    NamespaceId namespace=Ids.namespace(nm.getName());
    Collection<ApplicationSpecification> appSpecs=store.getAllApplications(namespace.toId());
    for (    ApplicationSpecification appSpec : appSpecs) {
switch (programType) {
case FLOW:
        for (        String programName : appSpec.getFlows().keySet()) {
          ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
          if (programId != null) {
            targetProgramId=programId;
            break;
          }
        }
      break;
case MAPREDUCE:
    for (    String programName : appSpec.getMapReduce().keySet()) {
      ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
      if (programId != null) {
        targetProgramId=programId;
        break;
      }
    }
  break;
case SPARK:
for (String programName : appSpec.getSpark().keySet()) {
  ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
  if (programId != null) {
    targetProgramId=programId;
    break;
  }
}
break;
case SERVICE:
for (String programName : appSpec.getServices().keySet()) {
ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
if (programId != null) {
targetProgramId=programId;
break;
}
}
break;
case WORKER:
for (String programName : appSpec.getWorkers().keySet()) {
ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
if (programId != null) {
targetProgramId=programId;
break;
}
}
break;
case WORKFLOW:
for (String programName : appSpec.getWorkflows().keySet()) {
ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
if (programId != null) {
targetProgramId=programId;
break;
}
}
break;
default :
LOG.debug("String_Node_Str" + programType.name());
break;
}
if (targetProgramId != null) {
break;
}
}
if (targetProgramId != null) {
break;
}
}
return targetProgramId;
}

Fixed version (ground truth):
/** 
 * Helper method to get   {@link ProgramId} for a RunRecord for type of program
 * @param programType Type of program to search
 * @param runId The target id of the {@link RunRecord} to find
 * @return the program id of the run record or {@code null} if does not exist.
 */
@Nullable private ProgramId retrieveProgramIdForRunRecord(ProgramType programType,String runId){
  List<NamespaceMeta> namespaceMetas=nsStore.list();
  ProgramId targetProgramId=null;
  for (  NamespaceMeta nm : namespaceMetas) {
    NamespaceId namespace=Ids.namespace(nm.getName());
    Collection<ApplicationSpecification> appSpecs=store.getAllApplications(namespace.toId());
    for (    ApplicationSpecification appSpec : appSpecs) {
switch (programType) {
case FLOW:
        for (        String programName : appSpec.getFlows().keySet()) {
          ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
          if (programId != null) {
            targetProgramId=programId;
            break;
          }
        }
      break;
case MAPREDUCE:
    for (    String programName : appSpec.getMapReduce().keySet()) {
      ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
      if (programId != null) {
        targetProgramId=programId;
        break;
      }
    }
  break;
case SPARK:
for (String programName : appSpec.getSpark().keySet()) {
  ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
  if (programId != null) {
    targetProgramId=programId;
    break;
  }
}
break;
case SERVICE:
for (String programName : appSpec.getServices().keySet()) {
ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
if (programId != null) {
targetProgramId=programId;
break;
}
}
break;
case WORKER:
for (String programName : appSpec.getWorkers().keySet()) {
ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
if (programId != null) {
targetProgramId=programId;
break;
}
}
break;
case WORKFLOW:
for (String programName : appSpec.getWorkflows().keySet()) {
ProgramId programId=validateProgramForRunRecord(nm.getName(),appSpec.getName(),programType,programName,runId);
if (programId != null) {
targetProgramId=programId;
break;
}
}
break;
case CUSTOM_ACTION:
case WEBAPP:
break;
default :
LOG.debug("String_Node_Str" + programType.name());
break;
}
if (targetProgramId != null) {
break;
}
}
if (targetProgramId != null) {
break;
}
}
return targetProgramId;
}